PageRenderTime 19ms CodeModel.GetById 14ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/Src/Dependencies/Boost/libs/static_assert/static_assert_example_3.cpp

http://hadesmem.googlecode.com/
C++ | 33 lines | 18 code | 7 blank | 8 comment | 3 complexity | f30883d7631f59caafd19e25c38a98c4 MD5 | raw file
 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
 6//  See http://www.boost.org for most recent version including documentation.
 7
 8#include <limits>
 9#include <boost/limits.hpp>
10#include <boost/static_assert.hpp>
11
12template <class UnsignedInt>
13class myclass
14{
15private:
16   BOOST_STATIC_ASSERT((std::numeric_limits<UnsignedInt>::digits >= 16)
17                        && std::numeric_limits<UnsignedInt>::is_specialized
18                        && std::numeric_limits<UnsignedInt>::is_integer
19                        && !std::numeric_limits<UnsignedInt>::is_signed);
20public:
21   /* details here */
22};
23
24myclass<unsigned>      m1; // this should be OK
25//myclass<int>           m2; // this should fail
26//myclass<unsigned char> m3; // and so should this
27
28int main()
29{
30   return 0;
31}
32
33