-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtuple_type.h
48 lines (41 loc) · 2.24 KB
/
tuple_type.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// (C) Copyright 2009-2011 Vit Kasal
//
// 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)
#pragma once
#include <boost/mpl/size.hpp>
#include <boost/mpl/at.hpp>
#include <boost/mpl/greater.hpp>
#include <boost/tuple/tuple.hpp>
#include <boost/utility/enable_if.hpp>
namespace boostext
{
template<typename sequence_tt> struct tuple_type
{
typedef typename boost::mpl::size<sequence_tt>::value_type size_type;
BOOST_STATIC_CONSTANT(size_type, max_size = 10);
// BOOST_MPL_ASSERT_MSG(boost::mpl::size<sequence_tt>::value <= max_size, SEQUENCE_TOO_LARGE_FOR_TUPLE_DEFINITION, (types<sequence_tt, typename boost::mpl::size<sequence_tt>::type, boost::mpl::integral_c<size_type, max_size>, boost::mpl::bool_<boost::mpl::size<sequence_tt>::value <= max_size> >));
template<typename position, typename enable = typename boost::mpl::greater<typename boost::mpl::size<sequence_tt>::type, position >::type > struct position_type
{
// BOOST_MPL_ASSERT_MSG(false, TUPLE_TYPE_OUT_OF_INPUT, (types< position, enable, sequence_tt >));
typedef boost::tuples::null_type type;
};
template<typename position> struct position_type<position, typename boost::mpl::bool_<true> >
{
// BOOST_MPL_ASSERT_MSG(false, TUPLE_TYPE_OUT_OF_INPUT, (types<position>));
typedef typename boost::mpl::at<sequence_tt, position>::type type;
};
typedef typename boost::tuple<
typename position_type<boost::mpl::integral_c<size_type, 0> >::type
, typename position_type<boost::mpl::integral_c<size_type, 1> >::type
, typename position_type<boost::mpl::integral_c<size_type, 2> >::type
, typename position_type<boost::mpl::integral_c<size_type, 3> >::type
, typename position_type<boost::mpl::integral_c<size_type, 4> >::type
, typename position_type<boost::mpl::integral_c<size_type, 5> >::type
, typename position_type<boost::mpl::integral_c<size_type, 6> >::type
, typename position_type<boost::mpl::integral_c<size_type, 7> >::type
, typename position_type<boost::mpl::integral_c<size_type, 8> >::type
, typename position_type<boost::mpl::integral_c<size_type, 9> >::type
> type;
};
}//namespace boostext