forked from boostorg/static_assert
Compare commits
6 Commits
svn-branch
...
svn-branch
Author | SHA1 | Date | |
---|---|---|---|
b9483200ca | |||
1663a635aa | |||
b9a3b24aef | |||
a0dac351fb | |||
c68b2114de | |||
48b6934f7f |
29
Jamfile
29
Jamfile
@ -1,29 +0,0 @@
|
||||
# copyright John Maddock 2003
|
||||
|
||||
subproject libs/static_assert ;
|
||||
# bring in the rules for testing
|
||||
import testing ;
|
||||
|
||||
test-suite static_assert :
|
||||
[ run static_assert_test.cpp ]
|
||||
# [ run static_assert_example_1.cpp ]
|
||||
[ run static_assert_example_2.cpp ]
|
||||
[ run static_assert_example_3.cpp ]
|
||||
[ compile-fail static_assert_test_fail_1.cpp ]
|
||||
[ compile-fail static_assert_test_fail_2.cpp ]
|
||||
[ compile-fail static_assert_test_fail_3.cpp ]
|
||||
[ compile-fail static_assert_test_fail_4.cpp ]
|
||||
[ compile-fail static_assert_test_fail_5.cpp ]
|
||||
[ compile-fail static_assert_test_fail_6.cpp ]
|
||||
[ compile-fail static_assert_test_fail_7.cpp ]
|
||||
[ compile-fail static_assert_test_fail_8.cpp ]
|
||||
[ compile-fail static_assert_test_fail_9.cpp ]
|
||||
[ compile-fail static_assert_test_fail_10.cpp ]
|
||||
;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,4 +1,7 @@
|
||||
# copyright John Maddock 2003
|
||||
# Use, modification and distribution are subject to the
|
||||
# Boost Software License, Version 1.0. (See accompanying file
|
||||
# LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
# bring in the rules for testing
|
||||
import testing ;
|
||||
@ -25,3 +28,4 @@ test-suite static_assert :
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -49,11 +49,12 @@ be an unsigned type. We can verify this at compile time as follows:
|
||||
|
||||
#include <climits>
|
||||
#include <cwchar>
|
||||
#include <limits>
|
||||
#include <boost/static_assert.hpp>
|
||||
|
||||
namespace my_conditions {
|
||||
|
||||
BOOST_STATIC_ASSERT(sizeof(int) * CHAR_BIT >= 32);
|
||||
BOOST_STATIC_ASSERT(std::numeric_limits<int>::digits >= 32);
|
||||
BOOST_STATIC_ASSERT(WCHAR_MIN >= 0);
|
||||
|
||||
} // namespace my_conditions
|
||||
@ -61,7 +62,7 @@ be an unsigned type. We can verify this at compile time as follows:
|
||||
The use of the namespace my_conditions here requires some comment.
|
||||
The macro `BOOST_STATIC_ASSERT` works by generating an typedef declaration,
|
||||
and since the typedef must have a name, the macro generates one automatically by
|
||||
mangling a stub name with the value of __LINE__. When `BOOST_STATIC_ASSERT` is
|
||||
mangling a stub name with the value of `__LINE__`. When `BOOST_STATIC_ASSERT` is
|
||||
used at either class or function scope then each use of `BOOST_STATIC_ASSERT`
|
||||
is guaranteed to produce a name unique to that scope (provided you only use
|
||||
the macro once on each line). However when used in a header at namespace
|
||||
@ -128,8 +129,8 @@ using something like this:
|
||||
class myclass
|
||||
{
|
||||
private:
|
||||
BOOST_STATIC_ASSERT(sizeof(UnsignedInt) * CHAR_BIT >= 16);
|
||||
BOOST_STATIC_ASSERT(std::numeric_limits<UnsignedInt>::is_specialized
|
||||
BOOST_STATIC_ASSERT((std::numeric_limits<UnsignedInt>::digits >= 16)
|
||||
&& std::numeric_limits<UnsignedInt>::is_specialized
|
||||
&& std::numeric_limits<UnsignedInt>::is_integer
|
||||
&& !std::numeric_limits<UnsignedInt>::is_signed);
|
||||
public:
|
||||
@ -216,3 +217,5 @@ working at namespace, function, and class scope outweighed the ugliness of a mac
|
||||
]
|
||||
|
||||
[endsect]
|
||||
|
||||
|
||||
|
@ -28,6 +28,10 @@
|
||||
# define BOOST_SA_GCC_WORKAROUND
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_HAS_STATIC_ASSERT
|
||||
# define BOOST_STATIC_ASSERT( B ) static_assert(B, #B)
|
||||
#else
|
||||
|
||||
namespace boost{
|
||||
|
||||
// HP aCC cannot deal with missing names for template value parameters
|
||||
@ -111,7 +115,7 @@ template<int x> struct static_assert_test{};
|
||||
enum { BOOST_JOIN(boost_static_assert_enum_, __LINE__) \
|
||||
= sizeof(::boost::STATIC_ASSERTION_FAILURE< (bool)( B ) >) }
|
||||
#endif
|
||||
|
||||
#endif // ndef BOOST_HAS_STATIC_ASSERT
|
||||
|
||||
#endif // BOOST_STATIC_ASSERT_HPP
|
||||
|
||||
|
@ -9,6 +9,10 @@
|
||||
or view the online version at
|
||||
<a href="http://www.boost.org/regression-logs/cs-win32_metacomm/doc/html/boost_staticassert.html">
|
||||
http://www.boost.org/regression-logs/cs-win32_metacomm/doc/html/boost_staticassert.html</a>
|
||||
<P>Copyright John Maddock 2006</P>
|
||||
<P>Distributed under the Boost Software License, Version 1.0. (See accompanying file <A href="../../LICENSE_1_0.txt">
|
||||
LICENSE_1_0.txt</A> or copy at <A href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</A>).</P>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
@ -9,6 +9,10 @@
|
||||
or view the online version at
|
||||
<a href="http://www.boost.org/regression-logs/cs-win32_metacomm/doc/html/boost_staticassert.html">
|
||||
http://www.boost.org/regression-logs/cs-win32_metacomm/doc/html/boost_staticassert.html</a>
|
||||
<P>Copyright John Maddock 2006</P>
|
||||
<P>Distributed under the Boost Software License, Version 1.0. (See accompanying file <A href="../../LICENSE_1_0.txt">
|
||||
LICENSE_1_0.txt</A> or copy at <A href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</A>).</P>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include <climits>
|
||||
#include <cwchar>
|
||||
#include <limits>
|
||||
#include <boost/static_assert.hpp>
|
||||
|
||||
#if !defined(WCHAR_MIN)
|
||||
@ -16,7 +17,7 @@
|
||||
namespace boost{
|
||||
|
||||
namespace my_conditions {
|
||||
BOOST_STATIC_ASSERT(sizeof(int) * CHAR_BIT >= 32);
|
||||
BOOST_STATIC_ASSERT(std::numeric_limits<int>::digits >= 32);
|
||||
BOOST_STATIC_ASSERT(WCHAR_MIN >= 0);
|
||||
|
||||
} // namespace my_conditions
|
||||
@ -30,3 +31,4 @@ int main()
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -13,8 +13,8 @@ template <class UnsignedInt>
|
||||
class myclass
|
||||
{
|
||||
private:
|
||||
BOOST_STATIC_ASSERT(sizeof(UnsignedInt) * CHAR_BIT >= 16);
|
||||
BOOST_STATIC_ASSERT(std::numeric_limits<UnsignedInt>::is_specialized
|
||||
BOOST_STATIC_ASSERT((std::numeric_limits<UnsignedInt>::digits >= 16)
|
||||
&& std::numeric_limits<UnsignedInt>::is_specialized
|
||||
&& std::numeric_limits<UnsignedInt>::is_integer
|
||||
&& !std::numeric_limits<UnsignedInt>::is_signed);
|
||||
public:
|
||||
@ -30,3 +30,4 @@ int main()
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user