correctly_disable_fail.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // Copyright 2011 Daniel James.
  2. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  3. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  4. // This tests if container forwarding is correctly disabled. If it isn't
  5. // disabled it causes a compile error (which causes the test to pass).
  6. // If it is disabled it tries container forwarding. If it doesn't work
  7. // then there will be a compile error, indicating that it is correctly
  8. // disabled. But if there isn't a compile error that indicates that
  9. // container forwarding might work.
  10. //
  11. // Since this test only tries std::vector, it might get it wrong but I didn't
  12. // want it to fail because of some incompatibility with a trickier class.
  13. #define BOOST_DETAIL_TEST_CONFIG_ONLY
  14. #include <boost/detail/container_fwd.hpp>
  15. #if !defined(BOOST_DETAIL_NO_CONTAINER_FWD)
  16. #error "Failing in order to pass test"
  17. #else
  18. #define BOOST_DETAIL_TEST_FORCE_CONTAINER_FWD
  19. #undef BOOST_DETAIL_CONTAINER_FWD_HPP
  20. #undef BOOST_DETAIL_TEST_CONFIG_ONLY
  21. #include <boost/detail/container_fwd.hpp>
  22. template <class T, class Allocator>
  23. void test(std::vector<T, Allocator> const&)
  24. {
  25. }
  26. #include <vector>
  27. int main ()
  28. {
  29. std::vector<int> x;
  30. test(x);
  31. }
  32. #endif