Move integer_sequence and tuple_for_each into mp11

This commit is contained in:
Peter Dimov
2017-05-23 20:24:37 +03:00
parent 6ebdd308e3
commit 29a771aa4e
12 changed files with 99 additions and 82 deletions
+2
View File
@@ -16,5 +16,7 @@
#include <boost/mp11/map.hpp>
#include <boost/mp11/set.hpp>
#include <boost/mp11/bind.hpp>
#include <boost/mp11/integer_sequence.hpp>
#include <boost/mp11/tuple_for_each.hpp>
#endif // #ifndef BOOST_MP11_HPP_INCLUDED
+1 -1
View File
@@ -17,7 +17,7 @@
#include <boost/mp11/detail/mp_plus.hpp>
#include <boost/mp11/detail/mp_map_find.hpp>
#include <boost/mp11/detail/config.hpp>
#include <boost/integer_sequence.hpp>
#include <boost/mp11/integer_sequence.hpp>
#include <boost/config.hpp>
#include <boost/detail/workaround.hpp>
#include <type_traits>
@@ -1,10 +1,19 @@
#ifndef BOOST_INTEGER_SEQUENCE_HPP_INCLUDED
#define BOOST_INTEGER_SEQUENCE_HPP_INCLUDED
#ifndef BOOST_MP11_INTEGER_SEQUENCE_HPP_INCLUDED
#define BOOST_MP11_INTEGER_SEQUENCE_HPP_INCLUDED
// Copyright 2015, 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 <cstddef>
namespace boost
{
namespace mp11
{
// integer_sequence
template<class T, T... I> struct integer_sequence
@@ -82,6 +91,7 @@ template<std::size_t N> using make_index_sequence = make_integer_sequence<std::s
// index_sequence_for
template<class... T> using index_sequence_for = make_integer_sequence<std::size_t, sizeof...(T)>;
} // namespace mp11
} // namespace boost
#endif // #ifndef BOOST_INTEGER_SEQUENCE_HPP_INCLUDED
#endif // #ifndef BOOST_MP11_INTEGER_SEQUENCE_HPP_INCLUDED
@@ -1,7 +1,14 @@
#ifndef BOOST_TUPLE_FOR_EACH_HPP_INCLUDED
#define BOOST_TUPLE_FOR_EACH_HPP_INCLUDED
#ifndef BOOST_MP11_TUPLE_FOR_EACH_HPP_INCLUDED
#define BOOST_MP11_TUPLE_FOR_EACH_HPP_INCLUDED
#include <boost/integer_sequence.hpp>
// Copyright 2015, 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 <boost/mp11/integer_sequence.hpp>
#include <boost/config.hpp>
#include <boost/detail/workaround.hpp>
#include <tuple>
@@ -11,11 +18,13 @@
namespace boost
{
namespace mp11
{
namespace detail
{
template<class Tp, std::size_t... J, class F> BOOST_CONSTEXPR F tuple_for_each_impl( Tp && tp, boost::integer_sequence<std::size_t, J...>, F && f )
template<class Tp, std::size_t... J, class F> BOOST_CONSTEXPR F tuple_for_each_impl( Tp && tp, integer_sequence<std::size_t, J...>, F && f )
{
using A = int[sizeof...(J)];
return (void)A{ ((void)f(std::get<J>(std::forward<Tp>(tp))), 0)... }, std::forward<F>(f);
@@ -23,7 +32,7 @@ template<class Tp, std::size_t... J, class F> BOOST_CONSTEXPR F tuple_for_each_i
#if BOOST_WORKAROUND( BOOST_MSVC, <= 1800 )
template<class Tp, class F> BOOST_CONSTEXPR F tuple_for_each_impl( Tp && tp, boost::integer_sequence<std::size_t>, F && f )
template<class Tp, class F> BOOST_CONSTEXPR F tuple_for_each_impl( Tp && tp, integer_sequence<std::size_t>, F && f )
{
return std::forward<F>(f);
}
@@ -34,10 +43,11 @@ template<class Tp, class F> BOOST_CONSTEXPR F tuple_for_each_impl( Tp && tp, boo
template<class Tp, class F> BOOST_CONSTEXPR F tuple_for_each( Tp && tp, F && f )
{
using seq = boost::make_index_sequence<std::tuple_size<typename std::remove_reference<Tp>::type>::value>;
using seq = make_index_sequence<std::tuple_size<typename std::remove_reference<Tp>::type>::value>;
return detail::tuple_for_each_impl( std::forward<Tp>(tp), seq(), std::forward<F>(f) );
}
} // namespace mp11
} // namespace boost
#endif // #ifndef BOOST_TUPLE_FOR_EACH_HPP_INCLUDED