Compare commits

..

1 Commits

Author SHA1 Message Date
9a7a7d05b9 This commit was manufactured by cvs2svn to create branch
'iter-adaptor-and-categories'.

[SVN r10453]
2001-06-27 22:12:20 +00:00
7 changed files with 33 additions and 37 deletions

16
Jamfile
View File

@ -1,16 +0,0 @@
subproject libs/static_assert ;
unit-test static_assert_test : static_assert_test.cpp
: <sysinclude>$(BOOST_ROOT) : ;
unit-test static_assert_example_1 : static_assert_example_1.cpp
: <sysinclude>$(BOOST_ROOT) : ;
unit-test static_assert_example_2 : static_assert_example_2.cpp
: <sysinclude>$(BOOST_ROOT) : ;
unit-test static_assert_example_3 : static_assert_example_3.cpp
: <sysinclude>$(BOOST_ROOT) : ;

View File

@ -8,8 +8,8 @@
/*
Revision history:
02 August 2000
Initial version.
02 August 2000
Initial version.
*/
#ifndef BOOST_STATIC_ASSERT_HPP
@ -62,7 +62,7 @@ template<int x> struct static_assert_test{};
#define BOOST_STATIC_ASSERT( B ) \
typedef ::boost::static_assert_test<\
sizeof(::boost::STATIC_ASSERTION_FAILURE< (bool)( B ) >)>\
BOOST_JOIN(boost_static_assert_typedef_, __LINE__)
BOOST_ASSERT_JOIN(boost_static_assert_typedef_, __LINE__)
#else
// __LINE__ macro broken when -ZI is used see Q199057
// fortunately MSVC ignores duplicate typedef's.
@ -74,10 +74,19 @@ template<int x> struct static_assert_test{};
#else
// alternative enum based implementation:
#define BOOST_STATIC_ASSERT( B ) \
enum { BOOST_JOIN(boost_static_assert_enum_, __LINE__) \
enum { BOOST_ASSERT_JOIN(boost_static_assert_enum_, __LINE__) \
= sizeof(::boost::STATIC_ASSERTION_FAILURE< (bool)( B ) >) }
#endif
//
// The following piece of macro magic joins the two
// arguments together, even when one of the arguments is
// itself a macro (see 16.3.1 in C++ standard). The key
// is that macro expansion of macro arguments does not
// occur in BOOST_DO_ASSERT_JOIN but does in BOOST_ASSERT_JOIN
// provided it is called from within another macro.
#define BOOST_ASSERT_JOIN( X, Y ) BOOST_DO_ASSERT_JOIN( X, Y )
#define BOOST_DO_ASSERT_JOIN( X, Y ) X##Y
#endif // BOOST_STATIC_ASSERT_HPP

View File

@ -131,7 +131,7 @@ argument, we can achieve this using something like this:</p>
<pre>#include &lt;climits&gt;
#include &lt;boost/static_assert.hpp&gt;
template &lt;class UnsignedInt&gt;
Template &lt;class UnsignedInt&gt;template &lt;class UnsignedInt&gt;
class myclass
{
private:

View File

@ -10,7 +10,7 @@
#include <cwchar>
#include <boost/static_assert.hpp>
#if !defined(WCHAR_MIN)
#if defined(__BORLANDC__) && !defined(WCHAR_MIN)
#define WCHAR_MIN 0
#endif
@ -29,4 +29,3 @@ int main()
return 0;
}

View File

@ -26,11 +26,11 @@ RandomAccessIterator foo(RandomAccessIterator from, RandomAccessIterator to)
int main()
{
std::deque<int> d;
std::list<int> l;
foo(d.begin(), d.end()); // OK
//foo(l.begin(), l.end()); // error
return 0;
std::deque<int> d;
std::list<int> l;
foo(d.begin(), d.end()); // OK
//foo(l.begin(), l.end()); // error
return 0;
}

View File

@ -13,6 +13,10 @@
// all these tests should fail:
//
#ifdef BOOST_MSVC
#error "VC6 not supported in this test (buggy compiler problem)"
#endif
struct Bob
{
@ -23,7 +27,7 @@ struct Bob
char c;
int f()
{
#if !defined(BOOST_MSVC) || BOOST_MSVC > 1200 // broken sizeof in VC6
#ifndef _MSC_VER // broken sizeof in VC6
BOOST_STATIC_ASSERT(sizeof(x) == 4);
BOOST_STATIC_ASSERT(sizeof(c) == 1);
BOOST_STATIC_ASSERT((sizeof(x) == sizeof(c))); // should not compile

View File

@ -12,12 +12,12 @@
#include <boost/static_assert.hpp>
#include <boost/type_traits.hpp>
template <class RandomAccessIterator >
RandomAccessIterator foo(RandomAccessIterator from, RandomAccessIterator)
template <class RandonAccessIterator >
RandonAccessIterator foo(RandonAccessIterator from, RandonAccessIterator to)
{
// this template can only be used with
// random access iterators...
typedef typename std::iterator_traits< RandomAccessIterator >::iterator_category cat;
typedef typename std::iterator_traits< RandonAccessIterator >::iterator_category cat;
BOOST_STATIC_ASSERT((boost::is_convertible<cat*, std::random_access_iterator_tag*>::value));
//
// detail goes here...
@ -26,11 +26,11 @@ RandomAccessIterator foo(RandomAccessIterator from, RandomAccessIterator)
int main()
{
std::deque<int> d;
std::list<int> l;
foo(d.begin(), d.end()); // OK
foo(l.begin(), l.end()); // error
return 0;
std::deque<int> d;
std::list<int> l;
foo(d.begin(), d.end()); // OK
foo(l.begin(), l.end()); // error
return 0;
}