static_assert_test_fail_9.cpp 937 B

1234567891011121314151617181920212223242526272829303132
  1. // (C) Copyright John Maddock 2000.
  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 for most recent version including documentation.
  6. #include <climits>
  7. #include <boost/limits.hpp>
  8. #include <boost/static_assert.hpp>
  9. template <class UnsignedInt>
  10. class myclass
  11. {
  12. private:
  13. BOOST_STATIC_ASSERT(sizeof(UnsignedInt) * CHAR_BIT >= 16);
  14. BOOST_STATIC_ASSERT(std::numeric_limits<UnsignedInt>::is_specialized
  15. && std::numeric_limits<UnsignedInt>::is_integer
  16. && !std::numeric_limits<UnsignedInt>::is_signed);
  17. public:
  18. /* details here */
  19. };
  20. myclass<unsigned> m1; // this should be OK
  21. //myclass<int> m2; // this should fail
  22. myclass<unsigned char> m3; // and so should this
  23. int main()
  24. {
  25. return 0;
  26. }