diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 18:24:20 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 18:24:20 +0000 |
commit | 483eb2f56657e8e7f419ab1a4fab8dce9ade8609 (patch) | |
tree | e5d88d25d870d5dedacb6bbdbe2a966086a0a5cf /src/boost/libs/mpl/test/assert.cpp | |
parent | Initial commit. (diff) | |
download | ceph-upstream.tar.xz ceph-upstream.zip |
Adding upstream version 14.2.21.upstream/14.2.21upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boost/libs/mpl/test/assert.cpp')
-rw-r--r-- | src/boost/libs/mpl/test/assert.cpp | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/src/boost/libs/mpl/test/assert.cpp b/src/boost/libs/mpl/test/assert.cpp new file mode 100644 index 00000000..b20f699d --- /dev/null +++ b/src/boost/libs/mpl/test/assert.cpp @@ -0,0 +1,101 @@ + +// Copyright Aleksey Gurtovoy 2000-2004 +// +// 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/assert.hpp> + +#include <boost/type_traits/is_same.hpp> +#include <boost/type_traits/is_pointer.hpp> + + +BOOST_MPL_ASSERT(( boost::is_same<int,int> )); +BOOST_MPL_ASSERT(( boost::is_pointer<int*> )); +BOOST_MPL_ASSERT_NOT(( boost::is_same<int,long> )); +BOOST_MPL_ASSERT_NOT(( boost::is_pointer<int> )); +BOOST_MPL_ASSERT_RELATION( 5, >, 1 ); +BOOST_MPL_ASSERT_RELATION( 1, <, 5 ); +BOOST_MPL_ASSERT_MSG( true, GLOBAL_SCOPE_ERROR, (int,long) ); +BOOST_MPL_ASSERT_MSG( true, ANOTHER_GLOBAL_SCOPE_ERROR, () ); + +namespace my { +BOOST_MPL_ASSERT(( boost::is_same<int,int> )); +BOOST_MPL_ASSERT(( boost::is_pointer<int*> )); +BOOST_MPL_ASSERT_NOT(( boost::is_same<int,long> )); +BOOST_MPL_ASSERT_NOT(( boost::is_pointer<int> )); +BOOST_MPL_ASSERT_RELATION( 5, >, 1 ); +BOOST_MPL_ASSERT_RELATION( 1, <, 5 ); +BOOST_MPL_ASSERT_MSG( true, GLOBAL_SCOPE_ERROR, (int,long) ); +BOOST_MPL_ASSERT_MSG( true, NAMESPACE_SCOPE_ERROR, () ); +BOOST_MPL_ASSERT_MSG( true, ANOTHER_NAMESPACE_SCOPE_ERROR, () ); +} + +template< typename T > +struct her +{ + BOOST_MPL_ASSERT(( boost::is_same<void,T> )); + BOOST_MPL_ASSERT(( boost::is_pointer<T*> )); + BOOST_MPL_ASSERT_NOT(( boost::is_same<int,T> )); + BOOST_MPL_ASSERT_NOT(( boost::is_pointer<T> )); + BOOST_MPL_ASSERT_RELATION( sizeof(T*), >, 1 ); + BOOST_MPL_ASSERT_RELATION( 1, <, sizeof(T*) ); + BOOST_MPL_ASSERT_MSG( true, GLOBAL_SCOPE_ERROR, (int,long) ); + BOOST_MPL_ASSERT_MSG( true, CLASS_SCOPE_ERROR, () ); +#if !defined(BOOST_MPL_CFG_NO_DEFAULT_PARAMETERS_IN_NESTED_TEMPLATES) + BOOST_MPL_ASSERT_MSG( true, ANOTHER_CLASS_SCOPE_ERROR, (types<int, T>) ); +#endif + + void f() + { + BOOST_MPL_ASSERT(( boost::is_same<void,T> )); + BOOST_MPL_ASSERT(( boost::is_pointer<T*> )); + BOOST_MPL_ASSERT_NOT(( boost::is_same<int,T> )); + BOOST_MPL_ASSERT_NOT(( boost::is_pointer<T> )); + BOOST_MPL_ASSERT_RELATION( sizeof(T*), >, 1 ); + BOOST_MPL_ASSERT_RELATION( 1, <, sizeof(T*) ); +#if !BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3202)) + BOOST_MPL_ASSERT_MSG( true, GLOBAL_SCOPE_ERROR, (int,long) ); +#endif + BOOST_MPL_ASSERT_MSG( true, MEMBER_FUNCTION_SCOPE_ERROR, () ); +#if !defined(BOOST_MPL_CFG_NO_DEFAULT_PARAMETERS_IN_NESTED_TEMPLATES) + BOOST_MPL_ASSERT_MSG( true, ANOTHER_MEMBER_FUNCTION_SCOPE_ERROR, (types<int, T>) ); +#endif + } +}; + +template<class T> +struct nested : boost::mpl::true_ { + BOOST_MPL_ASSERT(( boost::is_pointer<T*> )); + BOOST_MPL_ASSERT_NOT(( boost::is_same<void,T> )); + BOOST_MPL_ASSERT_RELATION( sizeof(T*), >, 1 ); + BOOST_MPL_ASSERT_MSG( true, GLOBAL_SCOPE_ERROR, (int,long) ); +}; + +BOOST_MPL_ASSERT(( nested<int> )); +BOOST_MPL_ASSERT_NOT(( boost::mpl::not_<nested<unsigned> > )); + +int main() +{ + her<void> h; + h.f(); + + BOOST_MPL_ASSERT(( boost::is_same<int,int> )); + BOOST_MPL_ASSERT(( boost::is_pointer<int*> )); + BOOST_MPL_ASSERT_NOT(( boost::is_same<int,long> )); + BOOST_MPL_ASSERT_NOT(( boost::is_pointer<int> )); + BOOST_MPL_ASSERT_RELATION( 5, >, 1 ); + BOOST_MPL_ASSERT_RELATION( 1, <, 5 ); + BOOST_MPL_ASSERT_MSG( true, GLOBAL_SCOPE_ERROR, (int,long) ); + BOOST_MPL_ASSERT_MSG( true, FUNCTION_SCOPE_ERROR, () ); + BOOST_MPL_ASSERT_MSG( true, ANOTHER_FUNCTION_SCOPE_ERROR, () ); + + return 0; +} |