mirror of
https://github.com/boostorg/static_assert.git
synced 2025-07-02 15:30:57 +02:00
Compare commits
5 Commits
svn-branch
...
boost-1.35
Author | SHA1 | Date | |
---|---|---|---|
1218a75c58 | |||
481c2efbac | |||
3b702727b9 | |||
f298ed51a9 | |||
851fd2622e |
@ -15,11 +15,11 @@
|
||||
[last-revision $Date$]
|
||||
]
|
||||
|
||||
[section:intro Overview and Tutorial]
|
||||
This manual is also available in
|
||||
[@http:svn.boost.org/svn/boost/sandbox/pdf/static_assert/release/static_assert.pdf
|
||||
printer friendly PDF format].
|
||||
|
||||
This documentation is
|
||||
[@http://boost-consulting.com/vault/index.php?action=downloadfile&filename=boost_static_assert-1.34.pdf&directory=PDF%20Documentation&
|
||||
also available in printer-friendly PDF format].
|
||||
[section:intro Overview and Tutorial]
|
||||
|
||||
The header `<boost/static_assert.hpp>` supplies a single macro `BOOST_STATIC_ASSERT(x)`,
|
||||
which generates a compile time error message if the integral-constant-expression `x`
|
||||
@ -98,12 +98,17 @@ the user that the template is being misused.
|
||||
#include <boost/type_traits.hpp>
|
||||
|
||||
template <class RandomAccessIterator >
|
||||
RandomAccessIterator foo(RandomAccessIterator from, RandomAccessIterator to)
|
||||
RandomAccessIterator foo(RandomAccessIterator from,
|
||||
RandomAccessIterator to)
|
||||
{
|
||||
// this template can only be used with
|
||||
// random access iterators...
|
||||
typedef typename std::iterator_traits< RandomAccessIterator >::iterator_category cat;
|
||||
BOOST_STATIC_ASSERT((boost::is_convertible<cat, const std::random_access_iterator_tag&>::value));
|
||||
typedef typename std::iterator_traits<
|
||||
RandomAccessIterator >::iterator_category cat;
|
||||
BOOST_STATIC_ASSERT(
|
||||
(boost::is_convertible<
|
||||
cat,
|
||||
const std::random_access_iterator_tag&>::value));
|
||||
//
|
||||
// detail goes here...
|
||||
return from;
|
||||
@ -223,4 +228,3 @@ 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
|
||||
|
||||
|
Reference in New Issue
Block a user