1
0
forked from boostorg/mp11

Merge branch 'develop'

This commit is contained in:
Peter Dimov
2017-06-02 19:59:23 +03:00
8 changed files with 2799 additions and 35 deletions

View File

@@ -16,7 +16,7 @@
#include <boost/mp11/detail/mp_count.hpp>
#include <boost/mp11/detail/mp_plus.hpp>
#include <boost/mp11/detail/mp_map_find.hpp>
#include <boost/mp11/detail/mp_for_index.hpp>
#include <boost/mp11/detail/mp_with_index.hpp>
#include <boost/mp11/detail/config.hpp>
#include <boost/mp11/integer_sequence.hpp>
#include <boost/config.hpp>

View File

@@ -1,5 +1,5 @@
#ifndef BOOST_MP11_DETAIL_MP_FOR_INDEX_HPP_INCLUDED
#define BOOST_MP11_DETAIL_MP_FOR_INDEX_HPP_INCLUDED
#ifndef BOOST_MP11_DETAIL_MP_WITH_INDEX_HPP_INCLUDED
#define BOOST_MP11_DETAIL_MP_WITH_INDEX_HPP_INCLUDED
// Copyright 2017 Peter Dimov.
//
@@ -28,7 +28,7 @@ namespace mp11
namespace detail
{
template<std::size_t N> struct mp_for_index_impl_
template<std::size_t N> struct mp_with_index_impl_
{
template<std::size_t K, class F> static BOOST_MP11_CONSTEXPR14 decltype(std::declval<F>()(std::declval<mp_size_t<0>>())) call( std::size_t i, F && f )
{
@@ -52,23 +52,23 @@ template<std::size_t N> struct mp_for_index_impl_
case 15: return std::forward<F>(f)( mp_size_t<K+15>() );
}
return mp_for_index_impl_<N-16>::template call<K+16>( i-16, std::forward<F>(f) );
return mp_with_index_impl_<N-16>::template call<K+16>( i-16, std::forward<F>(f) );
}
};
template<> struct mp_for_index_impl_<0>
template<> struct mp_with_index_impl_<0>
{
};
template<> struct mp_for_index_impl_<1>
template<> struct mp_with_index_impl_<1>
{
template<std::size_t K, class F> static BOOST_MP11_CONSTEXPR14 decltype(std::declval<F>()(std::declval<mp_size_t<0>>())) call( std::size_t i, F && f )
template<std::size_t K, class F> static BOOST_MP11_CONSTEXPR14 decltype(std::declval<F>()(std::declval<mp_size_t<0>>())) call( std::size_t /*i*/, F && f )
{
return std::forward<F>(f)( mp_size_t<K+0>() );
}
};
template<> struct mp_for_index_impl_<2>
template<> struct mp_with_index_impl_<2>
{
template<std::size_t K, class F> static BOOST_MP11_CONSTEXPR14 decltype(std::declval<F>()(std::declval<mp_size_t<0>>())) call( std::size_t i, F && f )
{
@@ -80,7 +80,7 @@ template<> struct mp_for_index_impl_<2>
}
};
template<> struct mp_for_index_impl_<3>
template<> struct mp_with_index_impl_<3>
{
template<std::size_t K, class F> static BOOST_MP11_CONSTEXPR14 decltype(std::declval<F>()(std::declval<mp_size_t<0>>())) call( std::size_t i, F && f )
{
@@ -93,7 +93,7 @@ template<> struct mp_for_index_impl_<3>
}
};
template<> struct mp_for_index_impl_<4>
template<> struct mp_with_index_impl_<4>
{
template<std::size_t K, class F> static BOOST_MP11_CONSTEXPR14 decltype(std::declval<F>()(std::declval<mp_size_t<0>>())) call( std::size_t i, F && f )
{
@@ -107,7 +107,7 @@ template<> struct mp_for_index_impl_<4>
}
};
template<> struct mp_for_index_impl_<5>
template<> struct mp_with_index_impl_<5>
{
template<std::size_t K, class F> static BOOST_MP11_CONSTEXPR14 decltype(std::declval<F>()(std::declval<mp_size_t<0>>())) call( std::size_t i, F && f )
{
@@ -122,7 +122,7 @@ template<> struct mp_for_index_impl_<5>
}
};
template<> struct mp_for_index_impl_<6>
template<> struct mp_with_index_impl_<6>
{
template<std::size_t K, class F> static BOOST_MP11_CONSTEXPR14 decltype(std::declval<F>()(std::declval<mp_size_t<0>>())) call( std::size_t i, F && f )
{
@@ -138,7 +138,7 @@ template<> struct mp_for_index_impl_<6>
}
};
template<> struct mp_for_index_impl_<7>
template<> struct mp_with_index_impl_<7>
{
template<std::size_t K, class F> static BOOST_MP11_CONSTEXPR14 decltype(std::declval<F>()(std::declval<mp_size_t<0>>())) call( std::size_t i, F && f )
{
@@ -155,7 +155,7 @@ template<> struct mp_for_index_impl_<7>
}
};
template<> struct mp_for_index_impl_<8>
template<> struct mp_with_index_impl_<8>
{
template<std::size_t K, class F> static BOOST_MP11_CONSTEXPR14 decltype(std::declval<F>()(std::declval<mp_size_t<0>>())) call( std::size_t i, F && f )
{
@@ -173,7 +173,7 @@ template<> struct mp_for_index_impl_<8>
}
};
template<> struct mp_for_index_impl_<9>
template<> struct mp_with_index_impl_<9>
{
template<std::size_t K, class F> static BOOST_MP11_CONSTEXPR14 decltype(std::declval<F>()(std::declval<mp_size_t<0>>())) call( std::size_t i, F && f )
{
@@ -192,7 +192,7 @@ template<> struct mp_for_index_impl_<9>
}
};
template<> struct mp_for_index_impl_<10>
template<> struct mp_with_index_impl_<10>
{
template<std::size_t K, class F> static BOOST_MP11_CONSTEXPR14 decltype(std::declval<F>()(std::declval<mp_size_t<0>>())) call( std::size_t i, F && f )
{
@@ -212,7 +212,7 @@ template<> struct mp_for_index_impl_<10>
}
};
template<> struct mp_for_index_impl_<11>
template<> struct mp_with_index_impl_<11>
{
template<std::size_t K, class F> static BOOST_MP11_CONSTEXPR14 decltype(std::declval<F>()(std::declval<mp_size_t<0>>())) call( std::size_t i, F && f )
{
@@ -233,7 +233,7 @@ template<> struct mp_for_index_impl_<11>
}
};
template<> struct mp_for_index_impl_<12>
template<> struct mp_with_index_impl_<12>
{
template<std::size_t K, class F> static BOOST_MP11_CONSTEXPR14 decltype(std::declval<F>()(std::declval<mp_size_t<0>>())) call( std::size_t i, F && f )
{
@@ -255,7 +255,7 @@ template<> struct mp_for_index_impl_<12>
}
};
template<> struct mp_for_index_impl_<13>
template<> struct mp_with_index_impl_<13>
{
template<std::size_t K, class F> static BOOST_MP11_CONSTEXPR14 decltype(std::declval<F>()(std::declval<mp_size_t<0>>())) call( std::size_t i, F && f )
{
@@ -278,7 +278,7 @@ template<> struct mp_for_index_impl_<13>
}
};
template<> struct mp_for_index_impl_<14>
template<> struct mp_with_index_impl_<14>
{
template<std::size_t K, class F> static BOOST_MP11_CONSTEXPR14 decltype(std::declval<F>()(std::declval<mp_size_t<0>>())) call( std::size_t i, F && f )
{
@@ -302,7 +302,7 @@ template<> struct mp_for_index_impl_<14>
}
};
template<> struct mp_for_index_impl_<15>
template<> struct mp_with_index_impl_<15>
{
template<std::size_t K, class F> static BOOST_MP11_CONSTEXPR14 decltype(std::declval<F>()(std::declval<mp_size_t<0>>())) call( std::size_t i, F && f )
{
@@ -327,7 +327,7 @@ template<> struct mp_for_index_impl_<15>
}
};
template<> struct mp_for_index_impl_<16>
template<> struct mp_with_index_impl_<16>
{
template<std::size_t K, class F> static BOOST_MP11_CONSTEXPR14 decltype(std::declval<F>()(std::declval<mp_size_t<0>>())) call( std::size_t i, F && f )
{
@@ -355,15 +355,15 @@ template<> struct mp_for_index_impl_<16>
} // namespace detail
template<std::size_t N, class F> inline BOOST_MP11_CONSTEXPR14 decltype(std::declval<F>()(std::declval<mp_size_t<0>>())) mp_for_index( std::size_t i, F && f )
template<std::size_t N, class F> inline BOOST_MP11_CONSTEXPR14 decltype(std::declval<F>()(std::declval<mp_size_t<0>>())) mp_with_index( std::size_t i, F && f )
{
assert( i < N );
return detail::mp_for_index_impl_<N>::template call<0>( i, std::forward<F>(f) );
return detail::mp_with_index_impl_<N>::template call<0>( i, std::forward<F>(f) );
}
template<class N, class F> inline BOOST_MP11_CONSTEXPR14 decltype(std::declval<F>()(std::declval<mp_size_t<0>>())) mp_for_index( std::size_t i, F && f )
template<class N, class F> inline BOOST_MP11_CONSTEXPR14 decltype(std::declval<F>()(std::declval<mp_size_t<0>>())) mp_with_index( std::size_t i, F && f )
{
return mp_for_index<N::value>( i, std::forward<F>(f) );
return mp_with_index<std::size_t{N::value}>( i, std::forward<F>(f) );
}
#undef BOOST_MP11_CONSTEXPR14
@@ -371,4 +371,4 @@ template<class N, class F> inline BOOST_MP11_CONSTEXPR14 decltype(std::declval<F
} // namespace mp11
} // namespace boost
#endif // #ifndef BOOST_MP11_DETAIL_MP_FIND_INDEX_HPP_INCLUDED
#endif // #ifndef BOOST_MP11_DETAIL_MP_WITH_INDEX_HPP_INCLUDED

File diff suppressed because it is too large Load Diff

View File

@@ -71,8 +71,8 @@ run mp_replace_at_c.cpp : : : $(REQ) ;
run mp_for_each.cpp : : : $(REQ) ;
run mp_insert.cpp : : : $(REQ) ;
run mp_erase.cpp : : : $(REQ) ;
run mp_for_index.cpp : : : $(REQ) ;
run mp_for_index_cx.cpp : : : $(REQ) ;
run mp_with_index.cpp : : : $(REQ) ;
run mp_with_index_cx.cpp : : : $(REQ) ;
# integral
run integral.cpp : : : $(REQ) ;

View File

@@ -15,7 +15,7 @@
using boost::mp11::mp_size_t;
using boost::mp11::mp_for_each;
using boost::mp11::mp_for_index;
using boost::mp11::mp_with_index;
using boost::mp11::mp_iota_c;
struct F
@@ -41,8 +41,8 @@ struct G
{
for( std::size_t i = 0; i < N; ++i )
{
mp_for_index<N>( i, F(i) );
mp_for_index<mp_size_t<N>>( i, F(i) );
mp_with_index<N>( i, F(i) );
mp_with_index<mp_size_t<N>>( i, F(i) );
}
}
};

View File

@@ -20,7 +20,7 @@ int main() {}
#include <boost/detail/workaround.hpp>
using boost::mp11::mp_size_t;
using boost::mp11::mp_for_index;
using boost::mp11::mp_with_index;
struct F
{
@@ -34,7 +34,7 @@ struct F
int main()
{
constexpr std::size_t i = mp_for_index<64>( 57, F{} );
constexpr std::size_t i = mp_with_index<64>( 57, F{} );
STATIC_ASSERT( i == 57 );
}

1
tools/single-header.bat Normal file
View File

@@ -0,0 +1 @@
python2.7 tools\single-header.py > include\boost\mp11_single.hpp

54
tools/single-header.py Normal file
View File

@@ -0,0 +1,54 @@
# 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
import os.path
import re
import sys
included = []
def scan_header( prefix, dir, fn ):
path = os.path.join( prefix, dir, fn )
if path in included:
return
included.append( path )
with open( path, 'r' ) as header:
for line in header:
m = re.match( '[ \t]*#[ \t]*include[ \t]*(["<])([^">]*)[">]', line )
r = False
if m:
h = m.group( 2 )
hfn1 = os.path.join( prefix, h )
hfn2 = os.path.join( prefix, dir, h )
if m.group( 1 ) == '"' and os.path.exists( hfn2 ):
scan_header( prefix, os.path.join( dir, os.path.dirname( hfn2 ) ), os.path.basename( hfn2 ) )
r = True
elif os.path.exists( hfn1 ):
scan_header( prefix, os.path.dirname( h ), os.path.basename( h ) )
r = True
if not r:
sys.stdout.write( line )
scan_header( 'include', 'boost', 'mp11.hpp' )