summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/mp11/test/mp_with_index.cpp
blob: 85a142d1699635d9597abf290799436f068527ef (plain)
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// 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 <boost/mp11/detail/config.hpp>

#if BOOST_MP11_MSVC
# pragma warning( disable: 4503 ) // decorated name length exceeded
#endif

#include <boost/mp11/algorithm.hpp>
#include <boost/mp11/detail/config.hpp>
#include <boost/core/lightweight_test.hpp>
#include <tuple>

using boost::mp11::mp_size_t;
using boost::mp11::mp_for_each;
using boost::mp11::mp_with_index;
using boost::mp11::mp_iota_c;

struct F
{
    std::size_t i_;

    explicit F( std::size_t i ): i_( i ) {}

    template<std::size_t I> bool operator()( mp_size_t<I> ) const
    {
        BOOST_TEST_EQ( I, i_ );
        return false;
    }
};

struct G
{
    void operator()( mp_size_t<0> ) const
    {
    }

    template<std::size_t N> void operator()( mp_size_t<N> ) const
    {
        for( std::size_t i = 0; i < N; ++i )
        {
            mp_with_index<N>( i, F(i) );
            mp_with_index<mp_size_t<N>>( i, F(i) );
        }
    }
};

int main()
{
#if BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, < 1900 )

    G()( mp_size_t<1>{} );
    G()( mp_size_t<2>{} );
    G()( mp_size_t<3>{} );
    G()( mp_size_t<4>{} );
    G()( mp_size_t<5>{} );
    G()( mp_size_t<6>{} );
    G()( mp_size_t<7>{} );
    G()( mp_size_t<8>{} );
    G()( mp_size_t<9>{} );
    G()( mp_size_t<10>{} );
    G()( mp_size_t<11>{} );
    G()( mp_size_t<12>{} );
    G()( mp_size_t<13>{} );
    G()( mp_size_t<14>{} );
    G()( mp_size_t<15>{} );
    G()( mp_size_t<16>{} );

    G()( mp_size_t<32+1>{} );

    G()( mp_size_t<48+2>{} );

    G()( mp_size_t<64+3>{} );

    G()( mp_size_t<96+4>{} );

    G()( mp_size_t<112+5>{} );

    G()( mp_size_t<128+6>{} );

#else

    mp_for_each<mp_iota_c<134>>( G() );

#endif

    return boost::report_errors();
}