1
0
forked from boostorg/mp11

Rename make_from_tuple to construct_from_tuple

This commit is contained in:
Peter Dimov
2017-06-08 19:22:53 +03:00
parent 19865f6145
commit cae6f966dc
7 changed files with 46 additions and 44 deletions

View File

@@ -592,7 +592,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
<li><a href="#tuple">Tuple Operations, &lt;boost/mp11/tuple.hpp&gt;</a>
<ul class="sectlevel3">
<li><a href="#tuple_apply_f_tp">tuple_apply(f, tp)</a></li>
<li><a href="#make_from_tuple_t_tp">make_from_tuple&lt;T&gt;(tp)</a></li>
<li><a href="#construct_from_tuple_t_tp">construct_from_tuple&lt;T&gt;(tp)</a></li>
<li><a href="#tuple_for_each_tp_f">tuple_for_each(tp, f)</a></li>
</ul>
</li>
@@ -2823,15 +2823,16 @@ where <code>N</code> is <code>std::tuple_size&lt;typename std::remove_reference&
</div>
</div>
<div class="sect3">
<h4 id="make_from_tuple_t_tp">make_from_tuple&lt;T&gt;(tp)</h4>
<h4 id="construct_from_tuple_t_tp">construct_from_tuple&lt;T&gt;(tp)</h4>
<div class="literalblock">
<div class="content">
<pre>template&lt;class T, class Tp&gt; T make_from_tuple(Tp&amp;&amp; tp);</pre>
<pre>template&lt;class T, class Tp&gt; T construct_from_tuple(Tp&amp;&amp; tp);</pre>
</div>
</div>
<div class="paragraph">
<p><code>make_from_tuple&lt;T&gt;(tp)</code> returns <code>T(std::get&lt;J&gt;(std::forward&lt;Tp&gt;(tp))&#8230;&#8203;)</code> for <code>J</code> in 0..<code>N-1</code>,
where <code>N</code> is <code>std::tuple_size&lt;typename std::remove_reference&lt;Tp&gt;::type&gt;::value</code>. Same as <code>std::make_from_tuple</code> in C++17.</p>
<p><code>construct_from_tuple&lt;T&gt;(tp)</code> returns <code>T(std::get&lt;J&gt;(std::forward&lt;Tp&gt;(tp))&#8230;&#8203;)</code> for <code>J</code> in 0..<code>N-1</code>,
where <code>N</code> is <code>std::tuple_size&lt;typename std::remove_reference&lt;Tp&gt;::type&gt;::value</code>. Same as <code>std::make_from_tuple</code> in C++17.
The name of the function doesn&#8217;t match the C++17 one to avoid ambiguities when both are visible or in unqualified calls.</p>
</div>
</div>
<div class="sect3">

View File

@@ -20,12 +20,13 @@ http://www.boost.org/LICENSE_1_0.txt
`tuple_apply(f, tp)` returns `std::forward<F>(f)(std::get<J>(std::forward<Tp>(tp))...)` for `J` in 0..`N-1`,
where `N` is `std::tuple_size<typename std::remove_reference<Tp>::type>::value`. Same as `std::apply` in C++17.
## make_from_tuple<T>(tp)
## construct_from_tuple<T>(tp)
template<class T, class Tp> T make_from_tuple(Tp&& tp);
template<class T, class Tp> T construct_from_tuple(Tp&& tp);
`make_from_tuple<T>(tp)` returns `T(std::get<J>(std::forward<Tp>(tp))...)` for `J` in 0..`N-1`,
where `N` is `std::tuple_size<typename std::remove_reference<Tp>::type>::value`. Same as `std::make_from_tuple` in C++17.
`construct_from_tuple<T>(tp)` returns `T(std::get<J>(std::forward<Tp>(tp))...)` for `J` in 0..`N-1`,
where `N` is `std::tuple_size<typename std::remove_reference<Tp>::type>::value`. Same as `std::make_from_tuple` in {cpp}17.
The name of the function doesn't match the {cpp}17 one to avoid ambiguities when both are visible or in unqualified calls.
## tuple_for_each(tp, f)

View File

@@ -41,11 +41,11 @@ BOOST_CONSTEXPR auto tuple_apply( F && f, Tp && tp )
return detail::tuple_apply_impl( std::forward<F>(f), std::forward<Tp>(tp), Seq() );
}
// make_from_tuple
// construct_from_tuple
namespace detail
{
template<class T, class Tp, std::size_t... J> BOOST_CONSTEXPR T make_from_tuple_impl( Tp && tp, integer_sequence<std::size_t, J...> )
template<class T, class Tp, std::size_t... J> BOOST_CONSTEXPR T construct_from_tuple_impl( Tp && tp, integer_sequence<std::size_t, J...> )
{
return T( std::get<J>(std::forward<Tp>(tp))... );
}
@@ -54,9 +54,9 @@ template<class T, class Tp, std::size_t... J> BOOST_CONSTEXPR T make_from_tuple_
template<class T, class Tp,
class Seq = make_index_sequence<std::tuple_size<typename std::remove_reference<Tp>::type>::value>>
BOOST_CONSTEXPR T make_from_tuple( Tp && tp )
BOOST_CONSTEXPR T construct_from_tuple( Tp && tp )
{
return detail::make_from_tuple_impl<T>( std::forward<Tp>(tp), Seq() );
return detail::construct_from_tuple_impl<T>( std::forward<Tp>(tp), Seq() );
}
// tuple_for_each

View File

@@ -2695,11 +2695,11 @@ BOOST_CONSTEXPR auto tuple_apply( F && f, Tp && tp )
return detail::tuple_apply_impl( std::forward<F>(f), std::forward<Tp>(tp), Seq() );
}
// make_from_tuple
// construct_from_tuple
namespace detail
{
template<class T, class Tp, std::size_t... J> BOOST_CONSTEXPR T make_from_tuple_impl( Tp && tp, integer_sequence<std::size_t, J...> )
template<class T, class Tp, std::size_t... J> BOOST_CONSTEXPR T construct_from_tuple_impl( Tp && tp, integer_sequence<std::size_t, J...> )
{
return T( std::get<J>(std::forward<Tp>(tp))... );
}
@@ -2708,9 +2708,9 @@ template<class T, class Tp, std::size_t... J> BOOST_CONSTEXPR T make_from_tuple_
template<class T, class Tp,
class Seq = make_index_sequence<std::tuple_size<typename std::remove_reference<Tp>::type>::value>>
BOOST_CONSTEXPR T make_from_tuple( Tp && tp )
BOOST_CONSTEXPR T construct_from_tuple( Tp && tp )
{
return detail::make_from_tuple_impl<T>( std::forward<Tp>(tp), Seq() );
return detail::construct_from_tuple_impl<T>( std::forward<Tp>(tp), Seq() );
}
// tuple_for_each

View File

@@ -95,11 +95,11 @@ run integer_sequence.cpp : : : $(REQ) ;
# tuple
run tuple_for_each.cpp : : : $(REQ) ;
run tuple_for_each_cx.cpp : : : $(REQ) ;
compile tuple_for_each_cx.cpp : : : $(REQ) ;
run tuple_apply.cpp : : : $(REQ) ;
run tuple_apply_cx.cpp : : : $(REQ) ;
run make_from_tuple.cpp : : : $(REQ) ;
run make_from_tuple_cx.cpp : : : $(REQ) ;
compile tuple_apply_cx.cpp : : : $(REQ) ;
run construct_from_tuple.cpp : : : $(REQ) ;
compile construct_from_tuple_cx.cpp : : : $(REQ) ;
# set
run mp_set_contains.cpp : : : $(REQ) ;

View File

@@ -38,13 +38,13 @@ struct T2
int main()
{
using boost::mp11::make_from_tuple;
using boost::mp11::construct_from_tuple;
{
std::tuple<int, short, char> tp{ 1, 2, 3 };
{
T1 t1 = make_from_tuple<T1>( tp );
T1 t1 = construct_from_tuple<T1>( tp );
BOOST_TEST_EQ( t1.x, 1 );
BOOST_TEST_EQ( t1.y, 2 );
@@ -52,7 +52,7 @@ int main()
}
{
T1 t1 = make_from_tuple<T1>( std::move(tp) );
T1 t1 = construct_from_tuple<T1>( std::move(tp) );
BOOST_TEST_EQ( t1.x, 1 );
BOOST_TEST_EQ( t1.y, 2 );
@@ -64,7 +64,7 @@ int main()
std::tuple<int, short, char> const tp{ 1, 2, 3 };
{
T1 t1 = make_from_tuple<T1>( tp );
T1 t1 = construct_from_tuple<T1>( tp );
BOOST_TEST_EQ( t1.x, 1 );
BOOST_TEST_EQ( t1.y, 2 );
@@ -72,7 +72,7 @@ int main()
}
{
T1 t1 = make_from_tuple<T1>( std::move(tp) );
T1 t1 = construct_from_tuple<T1>( std::move(tp) );
BOOST_TEST_EQ( t1.x, 1 );
BOOST_TEST_EQ( t1.y, 2 );
@@ -86,7 +86,7 @@ int main()
{
std::tuple<std::unique_ptr<int>, std::unique_ptr<int>, std::unique_ptr<int>> tp{ std::unique_ptr<int>(new int(1)), std::unique_ptr<int>(new int(2)), std::unique_ptr<int>(new int(3)) };
T2 t2 = make_from_tuple<T2>( std::move(tp) );
T2 t2 = construct_from_tuple<T2>( std::move(tp) );
BOOST_TEST_EQ( *t2.x, 1 );
BOOST_TEST_EQ( *t2.y, 2 );
@@ -99,7 +99,7 @@ int main()
std::pair<int, short> tp{ 1, 2 };
{
T1 t1 = make_from_tuple<T1>( tp );
T1 t1 = construct_from_tuple<T1>( tp );
BOOST_TEST_EQ( t1.x, 1 );
BOOST_TEST_EQ( t1.y, 2 );
@@ -107,7 +107,7 @@ int main()
}
{
T1 t1 = make_from_tuple<T1>( std::move(tp) );
T1 t1 = construct_from_tuple<T1>( std::move(tp) );
BOOST_TEST_EQ( t1.x, 1 );
BOOST_TEST_EQ( t1.y, 2 );
@@ -119,7 +119,7 @@ int main()
std::pair<int, short> const tp{ 1, 2 };
{
T1 t1 = make_from_tuple<T1>( tp );
T1 t1 = construct_from_tuple<T1>( tp );
BOOST_TEST_EQ( t1.x, 1 );
BOOST_TEST_EQ( t1.y, 2 );
@@ -127,7 +127,7 @@ int main()
}
{
T1 t1 = make_from_tuple<T1>( std::move(tp) );
T1 t1 = construct_from_tuple<T1>( std::move(tp) );
BOOST_TEST_EQ( t1.x, 1 );
BOOST_TEST_EQ( t1.y, 2 );
@@ -139,7 +139,7 @@ int main()
std::array<int, 3> tp{{ 1, 2, 3 }};
{
T1 t1 = make_from_tuple<T1>( tp );
T1 t1 = construct_from_tuple<T1>( tp );
BOOST_TEST_EQ( t1.x, 1 );
BOOST_TEST_EQ( t1.y, 2 );
@@ -147,7 +147,7 @@ int main()
}
{
T1 t1 = make_from_tuple<T1>( std::move(tp) );
T1 t1 = construct_from_tuple<T1>( std::move(tp) );
BOOST_TEST_EQ( t1.x, 1 );
BOOST_TEST_EQ( t1.y, 2 );
@@ -159,7 +159,7 @@ int main()
std::array<int, 3> const tp{{ 1, 2, 3 }};
{
T1 t1 = make_from_tuple<T1>( tp );
T1 t1 = construct_from_tuple<T1>( tp );
BOOST_TEST_EQ( t1.x, 1 );
BOOST_TEST_EQ( t1.y, 2 );
@@ -167,7 +167,7 @@ int main()
}
{
T1 t1 = make_from_tuple<T1>( std::move(tp) );
T1 t1 = construct_from_tuple<T1>( std::move(tp) );
BOOST_TEST_EQ( t1.x, 1 );
BOOST_TEST_EQ( t1.y, 2 );
@@ -179,7 +179,7 @@ int main()
std::tuple<> tp;
{
T1 t1 = make_from_tuple<T1>( tp );
T1 t1 = construct_from_tuple<T1>( tp );
BOOST_TEST_EQ( t1.x, 0 );
BOOST_TEST_EQ( t1.y, 0 );
@@ -187,7 +187,7 @@ int main()
}
{
T1 t1 = make_from_tuple<T1>( std::move(tp) );
T1 t1 = construct_from_tuple<T1>( std::move(tp) );
BOOST_TEST_EQ( t1.x, 0 );
BOOST_TEST_EQ( t1.y, 0 );
@@ -199,7 +199,7 @@ int main()
std::array<int, 0> tp;
{
T1 t1 = make_from_tuple<T1>( tp );
T1 t1 = construct_from_tuple<T1>( tp );
BOOST_TEST_EQ( t1.x, 0 );
BOOST_TEST_EQ( t1.y, 0 );
@@ -207,7 +207,7 @@ int main()
}
{
T1 t1 = make_from_tuple<T1>( std::move(tp) );
T1 t1 = construct_from_tuple<T1>( std::move(tp) );
BOOST_TEST_EQ( t1.x, 0 );
BOOST_TEST_EQ( t1.y, 0 );

View File

@@ -30,12 +30,12 @@ struct T1
int main()
{
using boost::mp11::make_from_tuple;
using boost::mp11::construct_from_tuple;
{
constexpr std::tuple<int, short, char> tp{ 1, 2, 3 };
constexpr auto r = make_from_tuple<T1>( tp );
constexpr auto r = construct_from_tuple<T1>( tp );
static_assert( r.x == 1, "r.x == 1" );
static_assert( r.y == 2, "r.y == 2" );
@@ -45,7 +45,7 @@ int main()
{
constexpr std::pair<short, char> tp{ 1, 2 };
constexpr auto r = make_from_tuple<T1>( tp );
constexpr auto r = construct_from_tuple<T1>( tp );
static_assert( r.x == 1, "r.x == 1" );
static_assert( r.y == 2, "r.y == 2" );
@@ -55,7 +55,7 @@ int main()
{
constexpr std::array<short, 3> tp{{ 1, 2, 3 }};
constexpr auto r = make_from_tuple<T1>( tp );
constexpr auto r = construct_from_tuple<T1>( tp );
static_assert( r.x == 1, "r.x == 1" );
static_assert( r.y == 2, "r.y == 2" );
@@ -69,7 +69,7 @@ int main()
{
constexpr std::tuple<> tp;
constexpr auto r = make_from_tuple<T1>( tp );
constexpr auto r = construct_from_tuple<T1>( tp );
static_assert( r.x == 0, "r.x == 0" );
static_assert( r.y == 0, "r.y == 0" );