diff --git a/doc/html/mp11.html b/doc/html/mp11.html index 367185b..fab4c02 100644 --- a/doc/html/mp11.html +++ b/doc/html/mp11.html @@ -607,6 +607,8 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
  • tuple_for_each(tp, f)
  • +
  • Convenience Header, <boost/mp11.hpp>
  • +
  • MPL Support, <boost/mp11/mpl.hpp>
  • Appendix A: Copyright and License
  • @@ -3880,6 +3882,33 @@ expression f(std::get<J>(std::forward<Tp>(tp))) for +
    +

    Convenience Header, <boost/mp11.hpp>

    +
    +

    The convenience header <boost/mp11.hpp> includes all of the +headers listed previously in this reference.

    +
    +
    +
    +

    MPL Support, <boost/mp11/mpl.hpp>

    +
    +

    The header <boost/mp11/mpl.hpp>, when included, defines the +necessary support infrastructure for mp_list and std::tuple +to be valid MPL sequences.

    +
    +
    + + + + + +
    +
    Note
    +
    +mpl.hpp is not included by <boost/mp11.hpp>. +
    +
    +
    diff --git a/doc/mp11/mp11.adoc b/doc/mp11/mp11.adoc new file mode 100644 index 0000000..0e573f6 --- /dev/null +++ b/doc/mp11/mp11.adoc @@ -0,0 +1,17 @@ +//// +Copyright 2017 Peter Dimov + +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 +//// + +[#mp11] +# Convenience Header, +:toc: +:toc-title: +:idprefix: + +The convenience header `` includes all of the +headers listed previously in this reference. diff --git a/doc/mp11/mpl.adoc b/doc/mp11/mpl.adoc new file mode 100644 index 0000000..29f1a90 --- /dev/null +++ b/doc/mp11/mpl.adoc @@ -0,0 +1,20 @@ +//// +Copyright 2017 Peter Dimov + +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 +//// + +[#mpl] +# MPL Support, +:toc: +:toc-title: +:idprefix: + +The header ``, when included, defines the +necessary support infrastructure for `mp_list` and `std::tuple` +to be valid link:../../../../libs/mpl[MPL] sequences. + +NOTE: `mpl.hpp` is not included by ``. diff --git a/doc/mp11/reference.adoc b/doc/mp11/reference.adoc index 208c9b3..d836ce8 100644 --- a/doc/mp11/reference.adoc +++ b/doc/mp11/reference.adoc @@ -37,4 +37,8 @@ include::integer_sequence.adoc[] include::tuple.adoc[] +include::mp11.adoc[] + +include::mpl.adoc[] + :leveloffset: -1 diff --git a/include/boost/mp11/mpl.hpp b/include/boost/mp11/mpl.hpp new file mode 100644 index 0000000..0e836cb --- /dev/null +++ b/include/boost/mp11/mpl.hpp @@ -0,0 +1,175 @@ +#ifndef BOOST_MP11_MPL_HPP_INCLUDED +#define BOOST_MP11_MPL_HPP_INCLUDED + +// Copyright 2017 Peter Dimov. +// +// 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 + +#include +#include +#include + +namespace boost +{ +namespace mpl +{ + +struct forward_iterator_tag; + +namespace aux +{ + +struct mp11_tag {}; + +template struct mp11_iterator +{ + using category = forward_iterator_tag; + + using type = mp11::mp_first; + using next = mp11_iterator>; +}; + +} // namespace aux + +// at + +template< typename Tag > struct at_impl; + +template<> struct at_impl +{ + template struct apply + { + using type = mp11::mp_at; + }; +}; + +// back + +template< typename Tag > struct back_impl; + +template<> struct back_impl +{ + template struct apply + { + using N = mp11::mp_size; + using type = mp11::mp_at_c; + }; +}; + +// begin + +template< typename Tag > struct begin_impl; + +template<> struct begin_impl +{ + template struct apply + { + using type = aux::mp11_iterator; + }; +}; + +// clear + +template< typename Tag > struct clear_impl; + +template<> struct clear_impl +{ + template struct apply + { + using type = mp11::mp_clear; + }; +}; + +// end + +template< typename Tag > struct end_impl; + +template<> struct end_impl +{ + template struct apply + { + using type = aux::mp11_iterator>; + }; +}; + +// front + +template< typename Tag > struct front_impl; + +template<> struct front_impl +{ + template struct apply + { + using type = mp11::mp_front; + }; +}; + +// pop_front + +template< typename Tag > struct pop_front_impl; + +template<> struct pop_front_impl +{ + template struct apply + { + using type = mp11::mp_pop_front; + }; +}; + +// push_back + +template< typename Tag > struct push_back_impl; + +template<> struct push_back_impl +{ + template struct apply + { + using type = mp11::mp_push_back; + }; +}; + +// push_front + +template< typename Tag > struct push_front_impl; + +template<> struct push_front_impl +{ + template struct apply + { + using type = mp11::mp_push_front; + }; +}; + +// sequence_tag + +template< typename Sequence > struct sequence_tag; + +template struct sequence_tag> +{ + using type = aux::mp11_tag; +}; + +template struct sequence_tag> +{ + using type = aux::mp11_tag; +}; + +// size + +template< typename Tag > struct size_impl; + +template<> struct size_impl +{ + template struct apply + { + using type = mp11::mp_size; + }; +}; + +} // namespace mpl +} // namespace boost + +#endif // #ifndef BOOST_MP11_MPL_HPP_INCLUDED diff --git a/test/Jamfile b/test/Jamfile index 210a3da..ead58f0 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -131,3 +131,6 @@ run mp_bind.cpp : : : $(REQ) ; run mp_bind_q.cpp : : : $(REQ) ; run mp_bind_front.cpp : : : $(REQ) ; run mp_bind_back.cpp : : : $(REQ) ; + +# mpl +run mpl.cpp : : : $(REQ) ; diff --git a/test/mpl.cpp b/test/mpl.cpp new file mode 100644 index 0000000..5e9551e --- /dev/null +++ b/test/mpl.cpp @@ -0,0 +1,108 @@ + +// Copyright 2017 Peter Dimov. +// +// 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 + + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +template using add_pointer_t = typename std::add_pointer::type; + +template void test() +{ + namespace mpl = boost::mpl; + using namespace boost::mp11; + + // intrinsics + + BOOST_TEST_TRAIT_TRUE((std::is_same>::type, mp_at_c>)); + BOOST_TEST_TRAIT_TRUE((std::is_same>::type, mp_at_c>)); + BOOST_TEST_TRAIT_TRUE((std::is_same>::type, mp_at_c>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same::type, mp_at_c>)); + BOOST_TEST_TRAIT_TRUE((std::is_same::type, mp_at_c>)); + BOOST_TEST_TRAIT_TRUE((std::is_same::type, mp_at_c>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same::type, float>)); + + BOOST_TEST_EQ((mpl::distance::type, typename mpl::end::type>::type::value), mp_size::value); + + BOOST_TEST_TRAIT_TRUE((std::is_same::type, mp_clear>)); + + BOOST_TEST_TRAIT_FALSE((typename mpl::empty::type)); + BOOST_TEST_TRAIT_TRUE((typename mpl::empty>::type)); + + BOOST_TEST_TRAIT_TRUE((std::is_same::type>::type, mp_pop_front>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same::type, mp_front>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same::type, void>::type, mp_push_front>)); + BOOST_TEST_TRAIT_TRUE((std::is_same::type, void>::type, mp_push_back>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same::type, L1>::type, mp_append>)); + + BOOST_TEST_TRAIT_TRUE((typename mpl::is_sequence::type)); + + BOOST_TEST_TRAIT_TRUE((std::is_same::type, mp_pop_front>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same::type, mp_push_back>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same::type, mp_push_front>)); + + BOOST_TEST_EQ((mpl::size::type::value), mp_size::value); + + // algorithms + + BOOST_TEST_TRAIT_TRUE((std::is_same>::type, mp_transform>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same::type, mp_reverse>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same::type, mp_remove>)); + + using L2 = typename mpl::copy>>::type; + using L3 = typename mpl::copy>>::type; + + BOOST_TEST_TRAIT_TRUE((std::is_same)); +} + +int main() +{ + using boost::mp11::mp_list; + + test>(); + test>(); // MPL instantiates the tuple, so no 'void' + + return boost::report_errors(); +}