boost_no_explicit_cvt_ops.ipp 896 B

123456789101112131415161718192021222324252627282930313233
  1. // (C) Copyright Beman Dawes 2008
  2. // Use, modification and distribution are subject to the
  3. // Boost Software License, Version 1.0. (See accompanying file
  4. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. // See http://www.boost.org/libs/config for more information.
  6. // MACRO: BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS
  7. // TITLE: C++0x explicit conversion operators unavailable
  8. // DESCRIPTION: The compiler does not support C++0x explicit conversion operators
  9. #if defined(__GNUC__) && !defined(__GXX_EXPERIMENTAL_CXX0X__) && !defined(BOOST_INTEL_STDCXX0X)
  10. # error This feature is not available in non-C++0x mode
  11. #endif
  12. namespace boost_no_cxx11_explicit_conversion_operators {
  13. void quiet_warning(int){}
  14. struct foo {
  15. explicit operator int() { return 1; }
  16. };
  17. int test()
  18. {
  19. foo f;
  20. int i = int(f);
  21. quiet_warning(i);
  22. return 0;
  23. }
  24. }