boost_no_inline_memb_init.ipp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // (C) Copyright John Maddock 2001.
  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 most recent version.
  6. // MACRO: BOOST_NO_INCLASS_MEMBER_INITIALIZATION
  7. // TITLE: inline member constant initialisation
  8. // DESCRIPTION: Compiler violates std::9.4.2/4.
  9. namespace boost_no_inclass_member_initialization{
  10. struct UDT{};
  11. template <bool b1, bool b2, bool b3, bool b4, bool b5, bool b6, bool b7>
  12. struct ice_or_helper
  13. {
  14. static const bool value = true;
  15. };
  16. template <>
  17. struct ice_or_helper<false, false, false, false, false, false, false>
  18. {
  19. static const bool value = false;
  20. };
  21. template <bool b1, bool b2, bool b3 = false, bool b4 = false, bool b5 = false, bool b6 = false, bool b7 = false>
  22. struct ice_or
  23. {
  24. static const bool value = ice_or_helper<b1, b2, b3, b4, b5, b6, b7>::value;
  25. };
  26. template <class T>
  27. struct is_int
  28. {
  29. static const bool value = false;
  30. };
  31. template <>
  32. struct is_int<int>
  33. {
  34. static const bool value = true;
  35. };
  36. #if defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7)))
  37. # define BOOST_UNUSED_ATTRIBUTE __attribute__((unused))
  38. #else
  39. # define BOOST_UNUSED_ATTRIBUTE
  40. #endif
  41. int test()
  42. {
  43. typedef int a1[ice_or< is_int<int>::value, is_int<UDT>::value>::value ? 1 : -1] BOOST_UNUSED_ATTRIBUTE;
  44. return 0;
  45. }
  46. }
  47. #undef BOOST_UNUSED_ATTRIBUTE