From 483eb2f56657e8e7f419ab1a4fab8dce9ade8609 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 20:24:20 +0200 Subject: Adding upstream version 14.2.21. Signed-off-by: Daniel Baumann --- src/boost/libs/static_assert/CMakeLists.txt | 16 +++ src/boost/libs/static_assert/Jamfile.v2 | 9 ++ src/boost/libs/static_assert/README.md | 36 +++++++ src/boost/libs/static_assert/example/Jamfile.v2 | 20 ++++ .../example/static_assert_example_1.cpp | 34 +++++++ .../example/static_assert_example_2.cpp | 40 ++++++++ .../example/static_assert_example_3.cpp | 33 +++++++ src/boost/libs/static_assert/index.html | 18 ++++ src/boost/libs/static_assert/meta/libraries.json | 16 +++ src/boost/libs/static_assert/static_assert.htm | 18 ++++ src/boost/libs/static_assert/test/Jamfile.v2 | 30 ++++++ .../libs/static_assert/test/static_assert_test.cpp | 107 +++++++++++++++++++++ .../test/static_assert_test_fail_1.cpp | 23 +++++ .../test/static_assert_test_fail_10.cpp | 18 ++++ .../test/static_assert_test_fail_2.cpp | 25 +++++ .../test/static_assert_test_fail_3.cpp | 39 ++++++++ .../test/static_assert_test_fail_4.cpp | 38 ++++++++ .../test/static_assert_test_fail_5.cpp | 39 ++++++++ .../test/static_assert_test_fail_6.cpp | 46 +++++++++ .../test/static_assert_test_fail_7.cpp | 31 ++++++ .../test/static_assert_test_fail_8.cpp | 44 +++++++++ .../test/static_assert_test_fail_9.cpp | 32 ++++++ 22 files changed, 712 insertions(+) create mode 100644 src/boost/libs/static_assert/CMakeLists.txt create mode 100644 src/boost/libs/static_assert/Jamfile.v2 create mode 100644 src/boost/libs/static_assert/README.md create mode 100644 src/boost/libs/static_assert/example/Jamfile.v2 create mode 100644 src/boost/libs/static_assert/example/static_assert_example_1.cpp create mode 100644 src/boost/libs/static_assert/example/static_assert_example_2.cpp create mode 100644 src/boost/libs/static_assert/example/static_assert_example_3.cpp create mode 100644 src/boost/libs/static_assert/index.html create mode 100644 src/boost/libs/static_assert/meta/libraries.json create mode 100644 src/boost/libs/static_assert/static_assert.htm create mode 100644 src/boost/libs/static_assert/test/Jamfile.v2 create mode 100644 src/boost/libs/static_assert/test/static_assert_test.cpp create mode 100644 src/boost/libs/static_assert/test/static_assert_test_fail_1.cpp create mode 100644 src/boost/libs/static_assert/test/static_assert_test_fail_10.cpp create mode 100644 src/boost/libs/static_assert/test/static_assert_test_fail_2.cpp create mode 100644 src/boost/libs/static_assert/test/static_assert_test_fail_3.cpp create mode 100644 src/boost/libs/static_assert/test/static_assert_test_fail_4.cpp create mode 100644 src/boost/libs/static_assert/test/static_assert_test_fail_5.cpp create mode 100644 src/boost/libs/static_assert/test/static_assert_test_fail_6.cpp create mode 100644 src/boost/libs/static_assert/test/static_assert_test_fail_7.cpp create mode 100644 src/boost/libs/static_assert/test/static_assert_test_fail_8.cpp create mode 100644 src/boost/libs/static_assert/test/static_assert_test_fail_9.cpp (limited to 'src/boost/libs/static_assert') diff --git a/src/boost/libs/static_assert/CMakeLists.txt b/src/boost/libs/static_assert/CMakeLists.txt new file mode 100644 index 00000000..33877bc8 --- /dev/null +++ b/src/boost/libs/static_assert/CMakeLists.txt @@ -0,0 +1,16 @@ +# Copyright 2018 Mike Dev +# Distributed under 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 + +cmake_minimum_required(VERSION 3.5) +project(BoostStaticAssert LANGUAGES CXX) + +add_library(boost_static_assert INTERFACE) +add_library(Boost::static_assert ALIAS boost_static_assert) + +target_include_directories(boost_static_assert INTERFACE include) + +target_link_libraries(boost_static_assert + INTERFACE + Boost::config +) diff --git a/src/boost/libs/static_assert/Jamfile.v2 b/src/boost/libs/static_assert/Jamfile.v2 new file mode 100644 index 00000000..7c0a96b3 --- /dev/null +++ b/src/boost/libs/static_assert/Jamfile.v2 @@ -0,0 +1,9 @@ +# 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 ; + +build-project test ; \ No newline at end of file diff --git a/src/boost/libs/static_assert/README.md b/src/boost/libs/static_assert/README.md new file mode 100644 index 00000000..c2900106 --- /dev/null +++ b/src/boost/libs/static_assert/README.md @@ -0,0 +1,36 @@ +Boost StaticAssert Library +============================ + +The Boost StaticAssert library provides static assertions for C++, this library is the ancestor to C++ native static_assert's and +can be used on older compilers which don't have that feature. + +The full documentation is available on [boost.org](http://www.boost.org/doc/libs/release/libs/static_assert). + +## Support, bugs and feature requests ## + +Bugs and feature requests can be reported through the [Gitub issue tracker](https://github.com/boostorg/static_assert/issues) +(see [open issues](https://github.com/boostorg/static_assert/issues) and +[closed issues](https://github.com/boostorg/static_assert/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aclosed)). + +You can submit your changes through a [pull request](https://github.com/boostorg/static_assert/pulls). + +There is no mailing-list specific to Boost StaticAssert, although you can use the general-purpose Boost [mailing-list](http://lists.boost.org/mailman/listinfo.cgi/boost-users) using the tag [static_assert]. + + +## Development ## + +Clone the whole boost project, which includes the individual Boost projects as submodules ([see boost+git doc](https://github.com/boostorg/boost/wiki/Getting-Started)): + + git clone https://github.com/boostorg/boost + cd boost + git submodule update --init + +The Boost StaticAssert Library is located in `libs/static_assert/`. + +### Running tests ### +First, make sure you are in `libs/static_assert/test`. +You can either run all the tests listed in `Jamfile.v2` or run a single test: + + ../../../b2 <- run all tests + ../../../b2 static_assert_test <- single test + diff --git a/src/boost/libs/static_assert/example/Jamfile.v2 b/src/boost/libs/static_assert/example/Jamfile.v2 new file mode 100644 index 00000000..0f3c356b --- /dev/null +++ b/src/boost/libs/static_assert/example/Jamfile.v2 @@ -0,0 +1,20 @@ +# 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 ; + +test-suite static_assert : +# [ run static_assert_example_1.cpp ] + [ run static_assert_example_2.cpp ] + [ run static_assert_example_3.cpp ] +; + + + + + + + diff --git a/src/boost/libs/static_assert/example/static_assert_example_1.cpp b/src/boost/libs/static_assert/example/static_assert_example_1.cpp new file mode 100644 index 00000000..14c529c3 --- /dev/null +++ b/src/boost/libs/static_assert/example/static_assert_example_1.cpp @@ -0,0 +1,34 @@ +// (C) Copyright Steve Cleary & John Maddock 2000. +// 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. + +#include +#include +#include +#include + +#if !defined(WCHAR_MIN) +#define WCHAR_MIN 0 +#endif + +namespace boost{ + +namespace my_conditions { +BOOST_STATIC_ASSERT(std::numeric_limits::digits >= 32); +BOOST_STATIC_ASSERT(WCHAR_MIN >= 0); + +} // namespace my_conditions + +} // namespace boost + +int main() +{ + return 0; +} + + + + diff --git a/src/boost/libs/static_assert/example/static_assert_example_2.cpp b/src/boost/libs/static_assert/example/static_assert_example_2.cpp new file mode 100644 index 00000000..38a284be --- /dev/null +++ b/src/boost/libs/static_assert/example/static_assert_example_2.cpp @@ -0,0 +1,40 @@ +// (C) Copyright John Maddock 2000. +// 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. + +#include +#include +#include +#include +#include + +template +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::value)); + // + // detail goes here... + return from; +} + +int main() +{ + std::deque d; + std::list l; + foo(d.begin(), d.end()); // OK + //foo(l.begin(), l.end()); // error + return 0; +} + + + + + + + diff --git a/src/boost/libs/static_assert/example/static_assert_example_3.cpp b/src/boost/libs/static_assert/example/static_assert_example_3.cpp new file mode 100644 index 00000000..1cc15450 --- /dev/null +++ b/src/boost/libs/static_assert/example/static_assert_example_3.cpp @@ -0,0 +1,33 @@ +// (C) Copyright John Maddock 2000. +// 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. + +#include +#include +#include + +template +class myclass +{ +private: + BOOST_STATIC_ASSERT((std::numeric_limits::digits >= 16) + && std::numeric_limits::is_specialized + && std::numeric_limits::is_integer + && !std::numeric_limits::is_signed); +public: + /* details here */ +}; + +myclass m1; // this should be OK +//myclass m2; // this should fail +//myclass m3; // and so should this + +int main() +{ + return 0; +} + + diff --git a/src/boost/libs/static_assert/index.html b/src/boost/libs/static_assert/index.html new file mode 100644 index 00000000..f1e6c323 --- /dev/null +++ b/src/boost/libs/static_assert/index.html @@ -0,0 +1,18 @@ + + + + + + + Automatic redirection failed, please go to + ../../doc/html/boost_staticassert.html + or view the online version at + + http://www.boost.org/regression-logs/cs-win32_metacomm/doc/html/boost_staticassert.html +

Copyright John Maddock 2006

+

Distributed under the Boost Software License, Version 1.0. (See accompanying file + LICENSE_1_0.txt or copy at www.boost.org/LICENSE_1_0.txt).

+ + + + diff --git a/src/boost/libs/static_assert/meta/libraries.json b/src/boost/libs/static_assert/meta/libraries.json new file mode 100644 index 00000000..6d0bd321 --- /dev/null +++ b/src/boost/libs/static_assert/meta/libraries.json @@ -0,0 +1,16 @@ +{ + "key": "static_assert", + "name": "Static Assert", + "authors": [ + "John Maddock" + ], + "description": "Static assertions (compile time assertions).", + "category": [ + "Correctness", + "Generic", + "Metaprogramming" + ], + "maintainers": [ + "John Maddock " + ] +} diff --git a/src/boost/libs/static_assert/static_assert.htm b/src/boost/libs/static_assert/static_assert.htm new file mode 100644 index 00000000..f1e6c323 --- /dev/null +++ b/src/boost/libs/static_assert/static_assert.htm @@ -0,0 +1,18 @@ + + + + + + + Automatic redirection failed, please go to + ../../doc/html/boost_staticassert.html + or view the online version at + + http://www.boost.org/regression-logs/cs-win32_metacomm/doc/html/boost_staticassert.html +

Copyright John Maddock 2006

+

Distributed under the Boost Software License, Version 1.0. (See accompanying file + LICENSE_1_0.txt or copy at www.boost.org/LICENSE_1_0.txt).

+ + + + diff --git a/src/boost/libs/static_assert/test/Jamfile.v2 b/src/boost/libs/static_assert/test/Jamfile.v2 new file mode 100644 index 00000000..acb28e7f --- /dev/null +++ b/src/boost/libs/static_assert/test/Jamfile.v2 @@ -0,0 +1,30 @@ +# 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 ; + +test-suite static_assert : + [ run static_assert_test.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 ] +; + +build-project ../example ; + + + + + + + diff --git a/src/boost/libs/static_assert/test/static_assert_test.cpp b/src/boost/libs/static_assert/test/static_assert_test.cpp new file mode 100644 index 00000000..bddebcb3 --- /dev/null +++ b/src/boost/libs/static_assert/test/static_assert_test.cpp @@ -0,0 +1,107 @@ +// (C) Copyright Steve Cleary & John Maddock 2000. +// 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. + +#include + +// +// all these tests should succeed. +// some of these tests are rather simplistic (ie useless) +// in order to ensure that they compile on all platforms. +// + +// Namespace scope +BOOST_STATIC_ASSERT(sizeof(int) >= sizeof(short)); +BOOST_STATIC_ASSERT(sizeof(char) == 1); +BOOST_STATIC_ASSERT_MSG(sizeof(int) >= sizeof(short), "msg1"); +BOOST_STATIC_ASSERT_MSG(sizeof(char) == 1, "msg2"); + +// Function (block) scope +void f() +{ + BOOST_STATIC_ASSERT(sizeof(int) >= sizeof(short)); + BOOST_STATIC_ASSERT(sizeof(char) == 1); + BOOST_STATIC_ASSERT_MSG(sizeof(int) >= sizeof(short), "msg3"); + BOOST_STATIC_ASSERT_MSG(sizeof(char) == 1, "msg4"); +} + +struct Bob +{ + private: // can be in private, to avoid namespace pollution + BOOST_STATIC_ASSERT(sizeof(int) >= sizeof(short)); + BOOST_STATIC_ASSERT(sizeof(char) == 1); + BOOST_STATIC_ASSERT_MSG(sizeof(int) >= sizeof(short), "msg5"); + BOOST_STATIC_ASSERT_MSG(sizeof(char) == 1, "msg6"); + public: + + // Member function scope: provides access to member variables + int x; + char c; + int f() + { +#if defined(_MSC_VER) && _MSC_VER < 1300 // broken sizeof in VC6 + BOOST_STATIC_ASSERT(sizeof(x) >= sizeof(short)); + BOOST_STATIC_ASSERT(sizeof(c) == 1); + BOOST_STATIC_ASSERT_MSG(sizeof(x) >= sizeof(short), "msg7"); + BOOST_STATIC_ASSERT_MSG(sizeof(c) == 1, "msg8"); +#endif + return x; + } +}; + + + +// Template class scope +template +struct Bill +{ + BOOST_STATIC_CONSTANT(int, value = 1); + private: // can be in private, to avoid namespace pollution + BOOST_STATIC_ASSERT(sizeof(Int) > sizeof(char)); + BOOST_STATIC_ASSERT_MSG(sizeof(Int) > sizeof(char), "msg9"); + public: + + // Template member function scope: provides access to member variables + Int x; + Char c; + template + void f(Int2 , Char2 ) + { + BOOST_STATIC_ASSERT(sizeof(Int) == sizeof(Int2)); + BOOST_STATIC_ASSERT(sizeof(Char) == sizeof(Char2)); + BOOST_STATIC_ASSERT_MSG(sizeof(Int) == sizeof(Int2), "msg10"); + BOOST_STATIC_ASSERT_MSG(sizeof(Char) == sizeof(Char2), "msg11"); + } +}; + +void test_Bill() // BOOST_STATIC_ASSERTs are not triggerred until instantiated +{ + Bill z; + //Bill bad; // will not compile + int i = 3; + char ch = 'a'; + z.f(i, ch); + //z.f(i, i); // should not compile +} + +int main() +{ + test_Bill(); + // + // Test variadic macro support: + // +#ifndef BOOST_NO_CXX11_VARIADIC_MACROS + BOOST_STATIC_ASSERT(Bill::value); +#ifndef BOOST_NO_CXX11_STATIC_ASSERT + BOOST_STATIC_ASSERT_MSG(Bill::value, "This is a message"); +#endif +#endif + return 0; +} + + + + diff --git a/src/boost/libs/static_assert/test/static_assert_test_fail_1.cpp b/src/boost/libs/static_assert/test/static_assert_test_fail_1.cpp new file mode 100644 index 00000000..d8e01075 --- /dev/null +++ b/src/boost/libs/static_assert/test/static_assert_test_fail_1.cpp @@ -0,0 +1,23 @@ +// (C) Copyright Steve Cleary & John Maddock 2000. +// 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. + +#include + +// +// all these tests should fail: +// +typedef char a1[2]; +typedef char a2[3]; + +// Namespace scope +BOOST_STATIC_ASSERT(sizeof(a1) == sizeof(a2)); // will not compile + + + + + + diff --git a/src/boost/libs/static_assert/test/static_assert_test_fail_10.cpp b/src/boost/libs/static_assert/test/static_assert_test_fail_10.cpp new file mode 100644 index 00000000..ddc2d1a5 --- /dev/null +++ b/src/boost/libs/static_assert/test/static_assert_test_fail_10.cpp @@ -0,0 +1,18 @@ +//~ Copyright 2005 Redshift Software, Inc. +//~ Distributed under the Boost Software License, Version 1.0. +//~ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) + +#include + +template +int foo() +{ + BOOST_STATIC_ASSERT( N < 2 ); + + return N; +} + +int main() +{ + return foo<5>(); +} diff --git a/src/boost/libs/static_assert/test/static_assert_test_fail_2.cpp b/src/boost/libs/static_assert/test/static_assert_test_fail_2.cpp new file mode 100644 index 00000000..c75de491 --- /dev/null +++ b/src/boost/libs/static_assert/test/static_assert_test_fail_2.cpp @@ -0,0 +1,25 @@ +// (C) Copyright Steve Cleary & John Maddock 2000. +// 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. + +#include + +// +// all these tests should fail: +// +typedef char a1[2]; +typedef char a2[3]; + +// Function (block) scope +void f() +{ + BOOST_STATIC_ASSERT(sizeof(a1) == sizeof(a2)); // should not compile +} + + + + + diff --git a/src/boost/libs/static_assert/test/static_assert_test_fail_3.cpp b/src/boost/libs/static_assert/test/static_assert_test_fail_3.cpp new file mode 100644 index 00000000..182658a4 --- /dev/null +++ b/src/boost/libs/static_assert/test/static_assert_test_fail_3.cpp @@ -0,0 +1,39 @@ +// (C) Copyright Steve Cleary & John Maddock 2000. +// 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. + +#include + +// +// 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(a1) == sizeof(a2)); // will not compile + public: + + // Member function scope: provides access to member variables + int x; + char c; + int f() + { +#ifndef _MSC_VER // broken sizeof in VC6 + BOOST_STATIC_ASSERT(sizeof(x) == 4); + BOOST_STATIC_ASSERT(sizeof(c) == 1); +#endif + return x; + } +}; + + + + + + diff --git a/src/boost/libs/static_assert/test/static_assert_test_fail_4.cpp b/src/boost/libs/static_assert/test/static_assert_test_fail_4.cpp new file mode 100644 index 00000000..89c27329 --- /dev/null +++ b/src/boost/libs/static_assert/test/static_assert_test_fail_4.cpp @@ -0,0 +1,38 @@ +// (C) Copyright Steve Cleary & John Maddock 2000. +// 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. + +#include +#include + +// +// all these tests should fail: +// + + +struct Bob +{ + public: + + // Member function scope: provides access to member variables + char x[4]; + char c; + int f() + { +#if !defined(BOOST_MSVC) || BOOST_MSVC > 1200 // 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 +#endif + return x; + } +}; + + + + + + diff --git a/src/boost/libs/static_assert/test/static_assert_test_fail_5.cpp b/src/boost/libs/static_assert/test/static_assert_test_fail_5.cpp new file mode 100644 index 00000000..155c199e --- /dev/null +++ b/src/boost/libs/static_assert/test/static_assert_test_fail_5.cpp @@ -0,0 +1,39 @@ +// (C) Copyright Steve Cleary & John Maddock 2000. +// 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. + +#include + +// +// all these tests should fail: +// + +// Template class scope +template +struct Bill +{ + private: // can be in private, to avoid namespace pollution + BOOST_STATIC_ASSERT(sizeof(Int) == 4); + BOOST_STATIC_ASSERT(sizeof(Int) == sizeof(Char)); // should not compile when instantiated + public: + + // Template member function scope: provides access to member variables + Int x; + Char c; + template + void f(Int2 , Char2 ) + { + BOOST_STATIC_ASSERT(sizeof(Int) == sizeof(Int2)); + BOOST_STATIC_ASSERT(sizeof(Char) == sizeof(Char2)); + //BOOST_STATIC_ASSERT(sizeof(Int) == sizeof(Char)); // should not compile when instantiated + } +}; + +Bill b; + + + + diff --git a/src/boost/libs/static_assert/test/static_assert_test_fail_6.cpp b/src/boost/libs/static_assert/test/static_assert_test_fail_6.cpp new file mode 100644 index 00000000..b41aa747 --- /dev/null +++ b/src/boost/libs/static_assert/test/static_assert_test_fail_6.cpp @@ -0,0 +1,46 @@ +// (C) Copyright Steve Cleary & John Maddock 2000. +// 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. + +#include + +// +// all these tests should fail: +// + +// Template class scope +template +struct Bill +{ + private: // can be in private, to avoid namespace pollution + BOOST_STATIC_ASSERT(sizeof(Int) == 4); + //BOOST_STATIC_ASSERT(sizeof(Int) == sizeof(Char)); // should not compile when instantiated + public: + + // Template member function scope: provides access to member variables + Int x; + Char c; + template + void f(Int2 , Char2 ) + { + BOOST_STATIC_ASSERT(sizeof(Int) == sizeof(Int2)); + BOOST_STATIC_ASSERT(sizeof(Char) == sizeof(Char2)); + BOOST_STATIC_ASSERT(sizeof(Int) == sizeof(Char)); // should not compile when instantiated + } +}; + +void foo() +{ + int i = 0; + char c = 0; + Bill b; + // this should fail: + b.f(i, c); +} + + + + diff --git a/src/boost/libs/static_assert/test/static_assert_test_fail_7.cpp b/src/boost/libs/static_assert/test/static_assert_test_fail_7.cpp new file mode 100644 index 00000000..7e901269 --- /dev/null +++ b/src/boost/libs/static_assert/test/static_assert_test_fail_7.cpp @@ -0,0 +1,31 @@ +// (C) Copyright John Maddock 2000. +// 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. + +#include +#include +#include + +template +class myclass +{ +private: + BOOST_STATIC_ASSERT(sizeof(UnsignedInt) * CHAR_BIT >= 16); + BOOST_STATIC_ASSERT(std::numeric_limits::is_specialized + && std::numeric_limits::is_integer + && !std::numeric_limits::is_signed); +public: + /* details here */ +}; + +myclass m2; // this should fail +myclass m3; // and so should this + +int main() +{ + return 0; +} + diff --git a/src/boost/libs/static_assert/test/static_assert_test_fail_8.cpp b/src/boost/libs/static_assert/test/static_assert_test_fail_8.cpp new file mode 100644 index 00000000..a087bb70 --- /dev/null +++ b/src/boost/libs/static_assert/test/static_assert_test_fail_8.cpp @@ -0,0 +1,44 @@ +// (C) Copyright John Maddock 2000. +// 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. + +#include +#include +#include +#include +#include + +template +RandomAccessIterator foo(RandomAccessIterator from, RandomAccessIterator) +{ + // 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::value)); + // + // detail goes here... + 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::iterator + foo(std::list::iterator, std::list::iterator); + +int main() +{ + std::deque d; + std::list l; + foo(d.begin(), d.end()); // OK + foo(l.begin(), l.end()); // error + return 0; +} + + + + + diff --git a/src/boost/libs/static_assert/test/static_assert_test_fail_9.cpp b/src/boost/libs/static_assert/test/static_assert_test_fail_9.cpp new file mode 100644 index 00000000..09e4af9e --- /dev/null +++ b/src/boost/libs/static_assert/test/static_assert_test_fail_9.cpp @@ -0,0 +1,32 @@ +// (C) Copyright John Maddock 2000. +// 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. + +#include +#include +#include + +template +class myclass +{ +private: + BOOST_STATIC_ASSERT(sizeof(UnsignedInt) * CHAR_BIT >= 16); + BOOST_STATIC_ASSERT(std::numeric_limits::is_specialized + && std::numeric_limits::is_integer + && !std::numeric_limits::is_signed); +public: + /* details here */ +}; + +myclass m1; // this should be OK +//myclass m2; // this should fail +myclass m3; // and so should this + +int main() +{ + return 0; +} + -- cgit v1.2.3