initialized_test_fail2.cpp 1006 B

12345678910111213141516171819202122232425262728293031323334353637
  1. // Copyright 2010, Niels Dekker.
  2. //
  3. // Distributed under the Boost Software License, Version 1.0. (See
  4. // accompanying file LICENSE_1_0.txt or copy at
  5. // http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. // Test program for boost::initialized<T>. Must fail to compile.
  8. //
  9. // Initial: 2 May 2010
  10. #include <boost/utility/value_init.hpp>
  11. namespace
  12. {
  13. void from_value_initialized_to_initialized()
  14. {
  15. boost::value_initialized<int> value_initialized_int;
  16. // Okay: initialized<T> can be initialized by value_initialized<T>.
  17. boost::initialized<int> initialized_int(value_initialized_int);
  18. }
  19. void from_initialized_to_value_initialized()
  20. {
  21. boost::initialized<int> initialized_int(13);
  22. // The following line should not compile, because initialized<T>
  23. // should not be convertible to value_initialized<T>.
  24. boost::value_initialized<int> value_initialized_int(initialized_int);
  25. }
  26. }
  27. int main()
  28. {
  29. // This should fail to compile, so there is no need to call any function.
  30. return 0;
  31. }