cmp_msvc_value_born_error.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*-----------------------------------------------------------------------------+
  2. Copyright (c) 2011-2011: Joachim Faulhaber
  3. +------------------------------------------------------------------------------+
  4. Distributed under the Boost Software License, Version 1.0.
  5. (See accompanying file LICENCE.txt or copy at
  6. http://www.boost.org/LICENSE_1_0.txt)
  7. +-----------------------------------------------------------------------------*/
  8. #define BOOST_TEST_MODULE icl::cmp_msvc_value_born_error unit test
  9. #include <boost/config.hpp>
  10. #include "../unit_test_unwarned.hpp"
  11. namespace unhelpful{
  12. // This declaration of a class template will cause
  13. // the compilation of line 17 to fail with syntax error C2059
  14. template<class T> class value{};
  15. }
  16. //--- affected code ---------------------------------------
  17. template <class Type> struct meta_attribute
  18. {
  19. BOOST_STATIC_CONSTANT(int, value = 0);
  20. };
  21. template <class Type> struct meta_predicate
  22. {
  23. BOOST_STATIC_CONSTANT(bool, value =
  24. ( meta_attribute<Type>::value < 1)
  25. //error C2059: syntax error : ')'
  26. //IF class template value declared before
  27. // ((meta_attribute<Type>::value) < 1) // Remedy#1 enclose into ()
  28. // ( meta_attribute<Type>::value <=0) // Remedy#2 use operator <=
  29. );
  30. };
  31. BOOST_AUTO_TEST_CASE(dummy)
  32. {
  33. BOOST_CHECK( meta_predicate<int>::value );
  34. }