Compare commits

..

19 Commits

Author SHA1 Message Date
f378c96f35 This commit was manufactured by cvs2svn to create branch
'function_signature_patches_1_31'.

[SVN r22633]
2004-04-13 12:19:16 +00:00
68545773d5 Changed tests to guarantee portability
[SVN r22245]
2004-02-12 11:29:47 +00:00
328b4fee16 MWCW 8.3 no longer needs the enum version. This fixes a problem in Spirit, because of two header files both having a static assert at the same line.
[SVN r21364]
2003-12-21 16:34:52 +00:00
21ab9ce12a stripped tabs
[SVN r21012]
2003-11-30 13:08:35 +00:00
0e39de168b Changed email address to john@johnmaddock.co.uk
[SVN r20472]
2003-10-24 11:13:42 +00:00
52bc1a8fb7 Added new licence info.
[SVN r20254]
2003-10-04 11:29:20 +00:00
0566bafd1d Changed licence to new Boost licnece
[SVN r20241]
2003-10-02 11:53:35 +00:00
a2c78d51be Updated licence
[SVN r20237]
2003-10-01 10:28:17 +00:00
d06c7261fc Add V2 Jamfile
[SVN r20224]
2003-09-30 08:05:42 +00:00
5e7c100b55 Use the import rule
[SVN r19968]
2003-09-08 17:38:49 +00:00
c26dde8e6e Force early instantiation so test works with delayed instantiation compilers (Greg Comeau)
[SVN r19378]
2003-07-31 00:11:24 +00:00
19e8840ad7 Added __COUNTER__ based version for VC7 and later.
[SVN r19043]
2003-07-11 11:01:55 +00:00
dd969b13ab Stop running example1 in the tests: it's intentionally non-portable.
[SVN r18823]
2003-06-17 10:50:02 +00:00
5ea5535e1a Added copyright
[SVN r18524]
2003-05-24 11:11:11 +00:00
64973e2132 add special version for SGI MIPSpro compiler
[SVN r18173]
2003-04-03 22:33:23 +00:00
02c6fb40a6 Modified Jamfile to use testing.jam
[SVN r16868]
2003-01-11 11:52:19 +00:00
5ea88d2e64 add or update See www.boost.org comments
[SVN r16708]
2002-12-27 16:51:53 +00:00
1029ee8032 Intel C++ fix
[SVN r15351]
2002-09-16 01:19:05 +00:00
f2732e699f init commit
[SVN r14977]
2002-08-19 23:29:18 +00:00
18 changed files with 159 additions and 84 deletions

31
Jamfile
View File

@ -1,16 +1,25 @@
# 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 ]
;
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) : ;

24
Jamfile.v2 Normal file
View File

@ -0,0 +1,24 @@
# copyright John Maddock 2003
# 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 ]
;

View File

@ -1,10 +1,9 @@
// (C) Copyright John Maddock 2000.
// Permission to copy, use, modify, sell and
// distribute this software is granted provided this copyright notice appears
// in all copies. This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
// 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)
// See http://www.boost.org for most recent version including documentation.
// See http://www.boost.org/libs/static_assert for documentation.
/*
Revision history:
@ -16,6 +15,7 @@
#define BOOST_STATIC_ASSERT_HPP
#include <boost/config.hpp>
#include <boost/detail/workaround.hpp>
#ifdef __BORLANDC__
//
@ -28,7 +28,7 @@ namespace boost{
// HP aCC cannot deal with missing names for template value parameters
template <bool x> struct STATIC_ASSERTION_FAILURE;
template <> struct STATIC_ASSERTION_FAILURE<true>{};
template <> struct STATIC_ASSERTION_FAILURE<true> { enum { value = 1 }; };
// HP aCC cannot deal with missing names for template value parameters
template<int x> struct static_assert_test{};
@ -57,20 +57,44 @@ template<int x> struct static_assert_test{};
// style casts: too many compilers currently have problems with static_cast
// when used inside integral constant expressions.
//
#if !defined(BOOST_BUGGY_INTEGRAL_CONSTANT_EXPRESSIONS) && !defined(__MWERKS__)
#ifndef BOOST_MSVC
#define BOOST_STATIC_ASSERT( B ) \
typedef ::boost::static_assert_test<\
sizeof(::boost::STATIC_ASSERTION_FAILURE< (bool)( B ) >)>\
BOOST_JOIN(boost_static_assert_typedef_, __LINE__)
#else
#if !defined(BOOST_BUGGY_INTEGRAL_CONSTANT_EXPRESSIONS) && \
!BOOST_WORKAROUND(__MWERKS__, < 0x3003)
#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
// __LINE__ macro broken when -ZI is used see Q199057
// fortunately MSVC ignores duplicate typedef's.
#define BOOST_STATIC_ASSERT( B ) \
typedef ::boost::static_assert_test<\
sizeof(::boost::STATIC_ASSERTION_FAILURE< (bool)( B ) >)\
> boost_static_assert_typedef_
#elif defined(BOOST_MSVC)
#define BOOST_STATIC_ASSERT( B ) \
typedef ::boost::static_assert_test<\
sizeof(::boost::STATIC_ASSERTION_FAILURE< (bool)( B ) >)>\
BOOST_JOIN(boost_static_assert_typedef_, __COUNTER__)
#elif defined(BOOST_INTEL_CXX_VERSION)
// agurt 15/sep/02: a special care is needed to force Intel C++ issue an error
// instead of warning in case of failure
# define BOOST_STATIC_ASSERT( B ) \
typedef char BOOST_JOIN(boost_static_assert_typedef_, __LINE__) \
[ ::boost::STATIC_ASSERTION_FAILURE< (bool)( B ) >::value ]
#elif defined(__sgi)
// special version for SGI MIPSpro compiler
#define BOOST_STATIC_ASSERT( B ) \
BOOST_STATIC_CONSTANT(bool, \
BOOST_JOIN(boost_static_assert_test_, __LINE__) = ( B )); \
typedef ::boost::static_assert_test<\
sizeof(::boost::STATIC_ASSERTION_FAILURE< \
BOOST_JOIN(boost_static_assert_test_, __LINE__) >)>\
BOOST_JOIN(boost_static_assert_typedef_, __LINE__)
#else
// generic version
#define BOOST_STATIC_ASSERT( B ) \
typedef ::boost::static_assert_test<\
sizeof(::boost::STATIC_ASSERTION_FAILURE< (bool)( B ) >)>\
BOOST_JOIN(boost_static_assert_typedef_, __LINE__)
#endif
#else
// alternative enum based implementation:
#define BOOST_STATIC_ASSERT( B ) \
@ -82,5 +106,3 @@ template<int x> struct static_assert_test{};
#endif // BOOST_STATIC_ASSERT_HPP

9
index.html Normal file
View File

@ -0,0 +1,9 @@
<html>
<head>
<meta http-equiv="refresh" content="0; URL=static_assert.htm">
</head>
<body>
Automatic redirection failed, please go to
<a href="static_assert.htm">static_assert.htm</a>.
</body>
</html>

View File

@ -265,7 +265,7 @@ warranty, and with no claim as to its suitability for any purpose.</p>
<p>Based on contributions by Steve Cleary and John Maddock.</p>
<p>Maintained by <a href="mailto:John_Maddock@compuserve.com">John
<p>Maintained by <a href="mailto:john@johnmaddock.co.uk">John
Maddock</a>, the latest version of this file can be found at <a
href="http://www.boost.org/">www.boost.org</a>, and the boost
discussion list at <a

View File

@ -1,8 +1,7 @@
// (C) Copyright Steve Cleary & John Maddock 2000.
// Permission to copy, use, modify, sell and
// distribute this software is granted provided this copyright notice appears
// in all copies. This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
// 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)
// See http://www.boost.org for most recent version including documentation.
@ -30,3 +29,4 @@ int main()
}

View File

@ -1,8 +1,7 @@
// (C) Copyright John Maddock 2000.
// Permission to copy, use, modify, sell and
// distribute this software is granted provided this copyright notice appears
// in all copies. This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
// 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)
// See http://www.boost.org for most recent version including documentation.
@ -38,3 +37,4 @@ int main()

View File

@ -1,8 +1,7 @@
// (C) Copyright John Maddock 2000.
// Permission to copy, use, modify, sell and
// distribute this software is granted provided this copyright notice appears
// in all copies. This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
// 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)
// See http://www.boost.org for most recent version including documentation.
@ -30,3 +29,4 @@ int main()
{
return 0;
}

View File

@ -1,8 +1,7 @@
// (C) Copyright Steve Cleary & John Maddock 2000.
// Permission to copy, use, modify, sell and
// distribute this software is granted provided this copyright notice appears
// in all copies. This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
// 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)
// See http://www.boost.org for most recent version including documentation.
@ -84,3 +83,4 @@ int main()

View File

@ -1,8 +1,7 @@
// (C) Copyright Steve Cleary & John Maddock 2000.
// Permission to copy, use, modify, sell and
// distribute this software is granted provided this copyright notice appears
// in all copies. This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
// 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)
// See http://www.boost.org for most recent version including documentation.
@ -11,9 +10,12 @@
//
// all these tests should fail:
//
typedef char a1[2];
typedef char a2[3];
// Namespace scope
BOOST_STATIC_ASSERT(sizeof(int) == sizeof(char)); // will not compile
BOOST_STATIC_ASSERT(sizeof(a1) == sizeof(a2)); // will not compile

View File

@ -1,8 +1,7 @@
// (C) Copyright Steve Cleary & John Maddock 2000.
// Permission to copy, use, modify, sell and
// distribute this software is granted provided this copyright notice appears
// in all copies. This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
// 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)
// See http://www.boost.org for most recent version including documentation.
@ -11,13 +10,16 @@
//
// all these tests should fail:
//
typedef char a1[2];
typedef char a2[3];
// Function (block) scope
void f()
{
BOOST_STATIC_ASSERT(sizeof(int) == sizeof(char)); // should not compile
BOOST_STATIC_ASSERT(sizeof(a1) == sizeof(a2)); // should not compile
}

View File

@ -1,8 +1,7 @@
// (C) Copyright Steve Cleary & John Maddock 2000.
// Permission to copy, use, modify, sell and
// distribute this software is granted provided this copyright notice appears
// in all copies. This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
// 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)
// See http://www.boost.org for most recent version including documentation.
@ -11,11 +10,13 @@
//
// this tests should fail:
//
typedef char a1[2];
typedef char a2[3];
struct Bob
{
private: // can be in private, to avoid namespace pollution
BOOST_STATIC_ASSERT(sizeof(int) == sizeof(char)); // will not compile
BOOST_STATIC_ASSERT(sizeof(a1) == sizeof(a2)); // will not compile
public:
// Member function scope: provides access to member variables
@ -27,7 +28,6 @@ struct Bob
BOOST_STATIC_ASSERT(sizeof(x) == 4);
BOOST_STATIC_ASSERT(sizeof(c) == 1);
#endif
//BOOST_STATIC_ASSERT((sizeof(x) == sizeof(c))); // should not compile
return x;
}
};
@ -36,3 +36,4 @@ struct Bob

View File

@ -1,8 +1,7 @@
// (C) Copyright Steve Cleary & John Maddock 2000.
// Permission to copy, use, modify, sell and
// distribute this software is granted provided this copyright notice appears
// in all copies. This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
// 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)
// See http://www.boost.org for most recent version including documentation.
@ -19,7 +18,7 @@ struct Bob
public:
// Member function scope: provides access to member variables
int x;
char x[4];
char c;
int f()
{
@ -36,3 +35,4 @@ struct Bob

View File

@ -1,8 +1,7 @@
// (C) Copyright Steve Cleary & John Maddock 2000.
// Permission to copy, use, modify, sell and
// distribute this software is granted provided this copyright notice appears
// in all copies. This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
// 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)
// See http://www.boost.org for most recent version including documentation.
@ -37,3 +36,4 @@ Bill<int, char> b;

View File

@ -1,8 +1,7 @@
// (C) Copyright Steve Cleary & John Maddock 2000.
// Permission to copy, use, modify, sell and
// distribute this software is granted provided this copyright notice appears
// in all copies. This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
// 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)
// See http://www.boost.org for most recent version including documentation.
@ -44,3 +43,4 @@ void foo()

View File

@ -1,8 +1,7 @@
// (C) Copyright John Maddock 2000.
// Permission to copy, use, modify, sell and
// distribute this software is granted provided this copyright notice appears
// in all copies. This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
// 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)
// See http://www.boost.org for most recent version including documentation.
@ -29,3 +28,4 @@ int main()
{
return 0;
}

View File

@ -1,8 +1,7 @@
// (C) Copyright John Maddock 2000.
// Permission to copy, use, modify, sell and
// distribute this software is granted provided this copyright notice appears
// in all copies. This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
// 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)
// See http://www.boost.org for most recent version including documentation.
@ -24,6 +23,12 @@ RandomAccessIterator foo(RandomAccessIterator from, RandomAccessIterator)
return from;
}
// ensure that delayed instantiation compilers like Comeau see the failure early
// enough for "compile-fail" testing with the Boost.Build testing framework. (Greg Comeau)
template
std::list<int>::iterator
foo(std::list<int>::iterator, std::list<int>::iterator);
int main()
{
std::deque<int> d;
@ -36,3 +41,4 @@ int main()

View File

@ -1,8 +1,7 @@
// (C) Copyright John Maddock 2000.
// Permission to copy, use, modify, sell and
// distribute this software is granted provided this copyright notice appears
// in all copies. This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
// 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)
// See http://www.boost.org for most recent version including documentation.
@ -30,3 +29,4 @@ int main()
{
return 0;
}