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/mpl/example/integer.cpp | 67 ++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 src/boost/libs/mpl/example/integer.cpp (limited to 'src/boost/libs/mpl/example/integer.cpp') diff --git a/src/boost/libs/mpl/example/integer.cpp b/src/boost/libs/mpl/example/integer.cpp new file mode 100644 index 00000000..879c4134 --- /dev/null +++ b/src/boost/libs/mpl/example/integer.cpp @@ -0,0 +1,67 @@ + +// Copyright Aleksey Gurtovoy 2001-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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace mpl = boost::mpl; +using namespace mpl::placeholders; + +template< int bit_size > +class big_int +{ + // ... +}; + +template< int bit_size > +struct integer +{ + typedef mpl::list builtins_; + typedef typename mpl::base< typename mpl::lower_bound< + mpl::transform_view< builtins_ + , mpl::multiplies< mpl::sizeof_<_1>, mpl::int_<8> > + > + , mpl::int_ + >::type >::type iter_; + + typedef typename mpl::end::type last_; + typedef typename mpl::eval_if< + boost::is_same + , mpl::identity< big_int > + , mpl::deref + >::type type; +}; + +typedef integer<1>::type int1; +typedef integer<5>::type int5; +typedef integer<15>::type int15; +typedef integer<32>::type int32; +typedef integer<100>::type int100; + +BOOST_MPL_ASSERT(( boost::is_same< int1, char > )); +BOOST_MPL_ASSERT(( boost::is_same< int5, char > )); +BOOST_MPL_ASSERT(( boost::is_same< int15, short > )); +BOOST_MPL_ASSERT(( boost::is_same< int32, int > )); +BOOST_MPL_ASSERT(( boost::is_same< int100, big_int<100> > )); -- cgit v1.2.3