fix for gcc 4.7~4.8

This commit is contained in:
bolero-MURAKAMI 2015-05-17 12:17:30 +09:00
parent fa619fc1bf
commit 4fecb5654c
5 changed files with 52 additions and 51 deletions

View file

@ -35,43 +35,42 @@ namespace sprout {
#endif #endif
template<int N> template<int N>
struct state { struct state
: public sprout::integral_constant<int, N>
{
friend SPROUT_CONSTEXPR int adl_counter(sprout::counter_detail::tag<N>) { friend SPROUT_CONSTEXPR int adl_counter(sprout::counter_detail::tag<N>) {
return N; return N;
} }
SPROUT_STATIC_CONSTEXPR int value = N;
}; };
template<int N>
SPROUT_CONSTEXPR_OR_CONST int sprout::counter_detail::state<N>::value;
template<int N, int = adl_counter(sprout::counter_detail::tag<N>())> template<int N, int = adl_counter(sprout::counter_detail::tag<N>())>
SPROUT_CONSTEXPR bool check_impl(int, sprout::counter_detail::tag<N>) { SPROUT_CONSTEXPR bool check(int, sprout::counter_detail::tag<N>) {
return true; return true;
} }
template<int N> template<int N>
SPROUT_CONSTEXPR bool check_impl(long, sprout::counter_detail::tag<N>) { SPROUT_CONSTEXPR bool check(long, sprout::counter_detail::tag<N>) {
return false; return false;
} }
template<int N> template<int N>
SPROUT_CONSTEXPR bool check(bool R = sprout::counter_detail::check_impl(0, sprout::counter_detail::tag<N>())) { SPROUT_CONSTEXPR bool check(bool R = sprout::counter_detail::check(0, sprout::counter_detail::tag<N>())) {
return R; return R;
} }
template<int N> template<int N>
SPROUT_CONSTEXPR int counter_impl(sprout::false_type, sprout::counter_detail::tag<N>) { SPROUT_CONSTEXPR int counter(sprout::false_type, sprout::counter_detail::tag<N>) {
return 0; return 0;
} }
template<int N> template<int N>
SPROUT_CONSTEXPR int counter_impl( SPROUT_CONSTEXPR int counter(
sprout::true_type, sprout::counter_detail::tag<N>, sprout::true_type, sprout::counter_detail::tag<N>,
int R = !sprout::counter_detail::check<N>() ? N int R = !sprout::counter_detail::check<N>() ? N
: counter_impl(sprout::bool_constant<sprout::counter_detail::check<N>()>(), sprout::counter_detail::tag<N + 1>()) : counter(sprout::bool_constant<sprout::counter_detail::check<N>()>(), sprout::counter_detail::tag<N + 1>())
) )
{ {
return R; return R;
} }
template<int N = 0> template<int N = 0>
SPROUT_CONSTEXPR int counter(int R = sprout::counter_detail::counter_impl(sprout::true_type(), sprout::counter_detail::tag<N>())) { SPROUT_CONSTEXPR int counter(int R = sprout::counter_detail::counter(sprout::true_type(), sprout::counter_detail::tag<N>())) {
return R; return R;
} }
} // namespace counter_detail } // namespace counter_detail

View file

@ -144,33 +144,33 @@ namespace sprout {
SPROUT_CONSTEXPR_OR_CONST int sprout::rand_detail::state<0, IsSrand, Seed>::value; SPROUT_CONSTEXPR_OR_CONST int sprout::rand_detail::state<0, IsSrand, Seed>::value;
template<int N, int = adl_counter(sprout::rand_detail::tag<N>())> template<int N, int = adl_counter(sprout::rand_detail::tag<N>())>
SPROUT_CONSTEXPR bool check_impl(int, sprout::rand_detail::tag<N>) { SPROUT_CONSTEXPR bool check(int, sprout::rand_detail::tag<N>) {
return true; return true;
} }
template<int N> template<int N>
SPROUT_CONSTEXPR bool check_impl(long, sprout::rand_detail::tag<N>) { SPROUT_CONSTEXPR bool check(long, sprout::rand_detail::tag<N>) {
return false; return false;
} }
template<int N> template<int N>
SPROUT_CONSTEXPR bool check(bool R = sprout::rand_detail::check_impl(0, sprout::rand_detail::tag<N>())) { SPROUT_CONSTEXPR bool check(bool R = sprout::rand_detail::check(0, sprout::rand_detail::tag<N>())) {
return R; return R;
} }
template<int N> template<int N>
SPROUT_CONSTEXPR int counter_impl(sprout::false_type, sprout::rand_detail::tag<N>) { SPROUT_CONSTEXPR int counter(sprout::false_type, sprout::rand_detail::tag<N>) {
return 0; return 0;
} }
template<int N> template<int N>
SPROUT_CONSTEXPR int counter_impl( SPROUT_CONSTEXPR int counter(
sprout::true_type, sprout::rand_detail::tag<N>, sprout::true_type, sprout::rand_detail::tag<N>,
int R = !sprout::rand_detail::check<N>() ? N int R = !sprout::rand_detail::check<N>() ? N
: counter_impl(sprout::bool_constant<sprout::rand_detail::check<N>()>(), sprout::rand_detail::tag<N + 1>()) : counter(sprout::bool_constant<sprout::rand_detail::check<N>()>(), sprout::rand_detail::tag<N + 1>())
) )
{ {
return R; return R;
} }
template<int N = 0> template<int N = 0>
SPROUT_CONSTEXPR int counter(int R = sprout::rand_detail::counter_impl(sprout::true_type(), sprout::rand_detail::tag<N>())) { SPROUT_CONSTEXPR int counter(int R = sprout::rand_detail::counter(sprout::true_type(), sprout::rand_detail::tag<N>())) {
return R; return R;
} }
} // namespace rand_detail } // namespace rand_detail

View file

@ -92,33 +92,33 @@ namespace sprout {
}; };
template<int N, int = adl_counter(sprout::slot_detail::tag<N>())> template<int N, int = adl_counter(sprout::slot_detail::tag<N>())>
SPROUT_CONSTEXPR bool check_impl(int, sprout::slot_detail::tag<N>) { SPROUT_CONSTEXPR bool check(int, sprout::slot_detail::tag<N>) {
return true; return true;
} }
template<int N> template<int N>
SPROUT_CONSTEXPR bool check_impl(long, sprout::slot_detail::tag<N>) { SPROUT_CONSTEXPR bool check(long, sprout::slot_detail::tag<N>) {
return false; return false;
} }
template<int N> template<int N>
SPROUT_CONSTEXPR bool check(bool R = sprout::slot_detail::check_impl(0, sprout::slot_detail::tag<N>())) { SPROUT_CONSTEXPR bool check(bool R = sprout::slot_detail::check(0, sprout::slot_detail::tag<N>())) {
return R; return R;
} }
template<int N> template<int N>
SPROUT_CONSTEXPR int counter_impl(sprout::false_type, sprout::slot_detail::tag<N>) { SPROUT_CONSTEXPR int counter(sprout::false_type, sprout::slot_detail::tag<N>) {
return 0; return 0;
} }
template<int N> template<int N>
SPROUT_CONSTEXPR int counter_impl( SPROUT_CONSTEXPR int counter(
sprout::true_type, sprout::slot_detail::tag<N>, sprout::true_type, sprout::slot_detail::tag<N>,
int R = !sprout::slot_detail::check_impl(0, sprout::slot_detail::tag<N>()) ? N int R = !sprout::slot_detail::check(0, sprout::slot_detail::tag<N>()) ? N
: counter_impl(sprout::bool_constant<sprout::slot_detail::check_impl(0, sprout::slot_detail::tag<N>())>(), sprout::slot_detail::tag<N + 1>()) : counter(sprout::bool_constant<sprout::slot_detail::check(0, sprout::slot_detail::tag<N>())>(), sprout::slot_detail::tag<N + 1>())
) )
{ {
return R; return R;
} }
template<int N = 0> template<int N = 0>
SPROUT_CONSTEXPR int counter(int R = sprout::slot_detail::counter_impl(sprout::true_type(), sprout::slot_detail::tag<N>())) { SPROUT_CONSTEXPR int counter(int R = sprout::slot_detail::counter(sprout::true_type(), sprout::slot_detail::tag<N>())) {
return R; return R;
} }
@ -156,16 +156,18 @@ namespace sprout {
// //
template< template<
int K, std::intmax_t Value, int K, std::intmax_t Value,
int N = 0,
std::intmax_t = sprout::slot_detail::state< std::intmax_t = sprout::slot_detail::state<
sprout::slot_detail::counter(), sprout::slot_detail::counter(sprout::true_type(), sprout::slot_detail::tag<N>()),
K, Value K, Value
>::value >::value
> >
SPROUT_CXX14_CONSTEXPR void assign_slot() {} SPROUT_CXX14_CONSTEXPR void assign_slot() {}
template< template<
int K, std::intmax_t Value, int K, std::intmax_t Value,
int N = 0,
std::intmax_t R = sprout::slot_detail::state< std::intmax_t R = sprout::slot_detail::state<
sprout::slot_detail::counter(), sprout::slot_detail::counter(sprout::true_type(), sprout::slot_detail::tag<N>()),
K, Value K, Value
>::value >::value
> >

View file

@ -47,33 +47,33 @@ namespace sprout {
}; };
template<int N, int = adl_counter(tag<N>())> template<int N, int = adl_counter(tag<N>())>
static SPROUT_CONSTEXPR bool check_impl(int, tag<N>) { static SPROUT_CONSTEXPR bool check(int, tag<N>) {
return true; return true;
} }
template<int N> template<int N>
static SPROUT_CONSTEXPR bool check_impl(long, tag<N>) { static SPROUT_CONSTEXPR bool check(long, tag<N>) {
return false; return false;
} }
template<int N> template<int N>
static SPROUT_CONSTEXPR bool check(bool R = check_impl(0, tag<N>())) { static SPROUT_CONSTEXPR bool check(bool R = check(0, tag<N>())) {
return R; return R;
} }
template<int N> template<int N>
static SPROUT_CONSTEXPR int counter_impl(sprout::false_type, tag<N>) { static SPROUT_CONSTEXPR int counter(sprout::false_type, tag<N>) {
return 0; return 0;
} }
template<int N> template<int N>
static SPROUT_CONSTEXPR int counter_impl( static SPROUT_CONSTEXPR int counter(
sprout::true_type, tag<N>, sprout::true_type, tag<N>,
int R = !check<N>() ? N int R = !check<N>() ? N
: counter_impl(sprout::bool_constant<check<N>()>(), tag<N + 1>()) : counter(sprout::bool_constant<check<N>()>(), tag<N + 1>())
) )
{ {
return R; return R;
} }
template<int N = 0> template<int N = 0>
static SPROUT_CONSTEXPR int counter(int R = counter_impl(sprout::true_type(), tag<N>())) { static SPROUT_CONSTEXPR int counter(int R = counter(sprout::true_type(), tag<N>())) {
return R; return R;
} }

View file

@ -93,33 +93,33 @@ namespace sprout {
}; };
template<int N, int = adl_counter(sprout::typed_slot_detail::tag<N>())> template<int N, int = adl_counter(sprout::typed_slot_detail::tag<N>())>
SPROUT_CONSTEXPR bool check_impl(int, sprout::typed_slot_detail::tag<N>) { SPROUT_CONSTEXPR bool check(int, sprout::typed_slot_detail::tag<N>) {
return true; return true;
} }
template<int N> template<int N>
SPROUT_CONSTEXPR bool check_impl(long, sprout::typed_slot_detail::tag<N>) { SPROUT_CONSTEXPR bool check(long, sprout::typed_slot_detail::tag<N>) {
return false; return false;
} }
template<int N> template<int N>
SPROUT_CONSTEXPR bool check(bool R = sprout::typed_slot_detail::check_impl(0, sprout::typed_slot_detail::tag<N>())) { SPROUT_CONSTEXPR bool check(bool R = sprout::typed_slot_detail::check(0, sprout::typed_slot_detail::tag<N>())) {
return R; return R;
} }
template<int N> template<int N>
SPROUT_CONSTEXPR int counter_impl(sprout::false_type, sprout::typed_slot_detail::tag<N>) { SPROUT_CONSTEXPR int counter(sprout::false_type, sprout::typed_slot_detail::tag<N>) {
return 0; return 0;
} }
template<int N> template<int N>
SPROUT_CONSTEXPR int counter_impl( SPROUT_CONSTEXPR int counter(
sprout::true_type, sprout::typed_slot_detail::tag<N>, sprout::true_type, sprout::typed_slot_detail::tag<N>,
int R = !sprout::typed_slot_detail::check<N>() ? N int R = !sprout::typed_slot_detail::check(0, sprout::typed_slot_detail::tag<N>()) ? N
: counter_impl(sprout::bool_constant<sprout::typed_slot_detail::check<N>()>(), sprout::typed_slot_detail::tag<N + 1>()) : counter(sprout::bool_constant<sprout::typed_slot_detail::check(0, sprout::typed_slot_detail::tag<N>())>(), sprout::typed_slot_detail::tag<N + 1>())
) )
{ {
return R; return R;
} }
template<int N = 0> template<int N = 0>
SPROUT_CONSTEXPR int counter(int R = sprout::typed_slot_detail::counter_impl(sprout::true_type(), sprout::typed_slot_detail::tag<N>())) { SPROUT_CONSTEXPR int counter(int R = sprout::typed_slot_detail::counter(sprout::true_type(), sprout::typed_slot_detail::tag<N>())) {
return R; return R;
} }
@ -130,8 +130,8 @@ namespace sprout {
template<int K, int N> template<int K, int N>
SPROUT_CONSTEXPR std::intmax_t get_impl( SPROUT_CONSTEXPR std::intmax_t get_impl(
sprout::true_type, sprout::typed_slot_detail::tag<N>, sprout::true_type, sprout::typed_slot_detail::tag<N>,
std::intmax_t R = !sprout::typed_slot_detail::check<N>() ? adl_get(sprout::typed_slot_detail::tag<N - 1>(), sprout::integral_constant<int, K>()) std::intmax_t R = !sprout::typed_slot_detail::check(0, sprout::typed_slot_detail::tag<N>()) ? adl_get(sprout::typed_slot_detail::tag<N - 1>(), sprout::integral_constant<int, K>())
: get_impl<K>(sprout::bool_constant<sprout::typed_slot_detail::check<N>()>(), sprout::typed_slot_detail::tag<N + 1>()) : get_impl<K>(sprout::bool_constant<sprout::typed_slot_detail::check(0, sprout::typed_slot_detail::tag<N>())>(), sprout::typed_slot_detail::tag<N + 1>())
) )
{ {
return R; return R;
@ -156,19 +156,19 @@ namespace sprout {
// assign_slot_return // assign_slot_return
// //
template< template<
typename T, typename T, std::intmax_t Value,
std::intmax_t Value, int N = 0,
std::intmax_t = sprout::typed_slot_detail::state< std::intmax_t = sprout::typed_slot_detail::state<
sprout::typed_slot_detail::counter(), sprout::typed_slot_detail::counter(sprout::true_type(), sprout::typed_slot_detail::tag<N>()),
sprout::typed_id<T>::value, Value sprout::typed_id<T>::value, Value
>::value >::value
> >
SPROUT_CXX14_CONSTEXPR void assign_slot() {} SPROUT_CXX14_CONSTEXPR void assign_slot() {}
template< template<
typename T, typename T, std::intmax_t Value,
std::intmax_t Value, int N = 0,
std::intmax_t R = sprout::typed_slot_detail::state< std::intmax_t R = sprout::typed_slot_detail::state<
sprout::typed_slot_detail::counter(), sprout::typed_slot_detail::counter(sprout::true_type(), sprout::typed_slot_detail::tag<N>()),
sprout::typed_id<T>::value, Value sprout::typed_id<T>::value, Value
>::value >::value
> >