mirror of
https://github.com/boostorg/mp11.git
synced 2025-12-06 16:39:20 +01:00
Make mp_for_each constexpr under C++14
This commit is contained in:
41
test/mp_for_index_cx.cpp
Normal file
41
test/mp_for_index_cx.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
|
||||
// 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/config.hpp>
|
||||
|
||||
#if defined( BOOST_NO_CXX14_CONSTEXPR )
|
||||
|
||||
int main() {}
|
||||
|
||||
#else
|
||||
|
||||
#include <boost/mp11/algorithm.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
using boost::mp11::mp_size_t;
|
||||
using boost::mp11::mp_for_index;
|
||||
|
||||
struct F
|
||||
{
|
||||
template<std::size_t I> constexpr std::size_t operator()( mp_size_t<I> ) const
|
||||
{
|
||||
return I;
|
||||
}
|
||||
};
|
||||
|
||||
#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)
|
||||
|
||||
int main()
|
||||
{
|
||||
constexpr std::size_t i = mp_for_index<64>( 57, F{} );
|
||||
STATIC_ASSERT( i == 57 );
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user