From 4fecb5654cc9968da7bf9c171fc6ff842ced62dd Mon Sep 17 00:00:00 2001 From: bolero-MURAKAMI Date: Sun, 17 May 2015 12:17:30 +0900 Subject: [PATCH] fix for gcc 4.7~4.8 --- sprout/stateful/counter.hpp | 21 ++++++++++----------- sprout/stateful/rand.hpp | 14 +++++++------- sprout/stateful/slot.hpp | 22 ++++++++++++---------- sprout/stateful/typed_id.hpp | 14 +++++++------- sprout/stateful/typed_slot.hpp | 32 ++++++++++++++++---------------- 5 files changed, 52 insertions(+), 51 deletions(-) diff --git a/sprout/stateful/counter.hpp b/sprout/stateful/counter.hpp index 46848d80..7734fea5 100644 --- a/sprout/stateful/counter.hpp +++ b/sprout/stateful/counter.hpp @@ -35,43 +35,42 @@ namespace sprout { #endif template - struct state { + struct state + : public sprout::integral_constant + { friend SPROUT_CONSTEXPR int adl_counter(sprout::counter_detail::tag) { return N; } - SPROUT_STATIC_CONSTEXPR int value = N; }; - template - SPROUT_CONSTEXPR_OR_CONST int sprout::counter_detail::state::value; template())> - SPROUT_CONSTEXPR bool check_impl(int, sprout::counter_detail::tag) { + SPROUT_CONSTEXPR bool check(int, sprout::counter_detail::tag) { return true; } template - SPROUT_CONSTEXPR bool check_impl(long, sprout::counter_detail::tag) { + SPROUT_CONSTEXPR bool check(long, sprout::counter_detail::tag) { return false; } template - SPROUT_CONSTEXPR bool check(bool R = sprout::counter_detail::check_impl(0, sprout::counter_detail::tag())) { + SPROUT_CONSTEXPR bool check(bool R = sprout::counter_detail::check(0, sprout::counter_detail::tag())) { return R; } template - SPROUT_CONSTEXPR int counter_impl(sprout::false_type, sprout::counter_detail::tag) { + SPROUT_CONSTEXPR int counter(sprout::false_type, sprout::counter_detail::tag) { return 0; } template - SPROUT_CONSTEXPR int counter_impl( + SPROUT_CONSTEXPR int counter( sprout::true_type, sprout::counter_detail::tag, int R = !sprout::counter_detail::check() ? N - : counter_impl(sprout::bool_constant()>(), sprout::counter_detail::tag()) + : counter(sprout::bool_constant()>(), sprout::counter_detail::tag()) ) { return R; } template - SPROUT_CONSTEXPR int counter(int R = sprout::counter_detail::counter_impl(sprout::true_type(), sprout::counter_detail::tag())) { + SPROUT_CONSTEXPR int counter(int R = sprout::counter_detail::counter(sprout::true_type(), sprout::counter_detail::tag())) { return R; } } // namespace counter_detail diff --git a/sprout/stateful/rand.hpp b/sprout/stateful/rand.hpp index 3e9541d0..cafe5283 100644 --- a/sprout/stateful/rand.hpp +++ b/sprout/stateful/rand.hpp @@ -144,33 +144,33 @@ namespace sprout { SPROUT_CONSTEXPR_OR_CONST int sprout::rand_detail::state<0, IsSrand, Seed>::value; template())> - SPROUT_CONSTEXPR bool check_impl(int, sprout::rand_detail::tag) { + SPROUT_CONSTEXPR bool check(int, sprout::rand_detail::tag) { return true; } template - SPROUT_CONSTEXPR bool check_impl(long, sprout::rand_detail::tag) { + SPROUT_CONSTEXPR bool check(long, sprout::rand_detail::tag) { return false; } template - SPROUT_CONSTEXPR bool check(bool R = sprout::rand_detail::check_impl(0, sprout::rand_detail::tag())) { + SPROUT_CONSTEXPR bool check(bool R = sprout::rand_detail::check(0, sprout::rand_detail::tag())) { return R; } template - SPROUT_CONSTEXPR int counter_impl(sprout::false_type, sprout::rand_detail::tag) { + SPROUT_CONSTEXPR int counter(sprout::false_type, sprout::rand_detail::tag) { return 0; } template - SPROUT_CONSTEXPR int counter_impl( + SPROUT_CONSTEXPR int counter( sprout::true_type, sprout::rand_detail::tag, int R = !sprout::rand_detail::check() ? N - : counter_impl(sprout::bool_constant()>(), sprout::rand_detail::tag()) + : counter(sprout::bool_constant()>(), sprout::rand_detail::tag()) ) { return R; } template - SPROUT_CONSTEXPR int counter(int R = sprout::rand_detail::counter_impl(sprout::true_type(), sprout::rand_detail::tag())) { + SPROUT_CONSTEXPR int counter(int R = sprout::rand_detail::counter(sprout::true_type(), sprout::rand_detail::tag())) { return R; } } // namespace rand_detail diff --git a/sprout/stateful/slot.hpp b/sprout/stateful/slot.hpp index 87a60e45..d5024518 100644 --- a/sprout/stateful/slot.hpp +++ b/sprout/stateful/slot.hpp @@ -92,33 +92,33 @@ namespace sprout { }; template())> - SPROUT_CONSTEXPR bool check_impl(int, sprout::slot_detail::tag) { + SPROUT_CONSTEXPR bool check(int, sprout::slot_detail::tag) { return true; } template - SPROUT_CONSTEXPR bool check_impl(long, sprout::slot_detail::tag) { + SPROUT_CONSTEXPR bool check(long, sprout::slot_detail::tag) { return false; } template - SPROUT_CONSTEXPR bool check(bool R = sprout::slot_detail::check_impl(0, sprout::slot_detail::tag())) { + SPROUT_CONSTEXPR bool check(bool R = sprout::slot_detail::check(0, sprout::slot_detail::tag())) { return R; } template - SPROUT_CONSTEXPR int counter_impl(sprout::false_type, sprout::slot_detail::tag) { + SPROUT_CONSTEXPR int counter(sprout::false_type, sprout::slot_detail::tag) { return 0; } template - SPROUT_CONSTEXPR int counter_impl( + SPROUT_CONSTEXPR int counter( sprout::true_type, sprout::slot_detail::tag, - int R = !sprout::slot_detail::check_impl(0, sprout::slot_detail::tag()) ? N - : counter_impl(sprout::bool_constant())>(), sprout::slot_detail::tag()) + int R = !sprout::slot_detail::check(0, sprout::slot_detail::tag()) ? N + : counter(sprout::bool_constant())>(), sprout::slot_detail::tag()) ) { return R; } template - SPROUT_CONSTEXPR int counter(int R = sprout::slot_detail::counter_impl(sprout::true_type(), sprout::slot_detail::tag())) { + SPROUT_CONSTEXPR int counter(int R = sprout::slot_detail::counter(sprout::true_type(), sprout::slot_detail::tag())) { return R; } @@ -156,16 +156,18 @@ namespace sprout { // template< int K, std::intmax_t Value, + int N = 0, std::intmax_t = sprout::slot_detail::state< - sprout::slot_detail::counter(), + sprout::slot_detail::counter(sprout::true_type(), sprout::slot_detail::tag()), K, Value >::value > SPROUT_CXX14_CONSTEXPR void assign_slot() {} template< int K, std::intmax_t Value, + int N = 0, std::intmax_t R = sprout::slot_detail::state< - sprout::slot_detail::counter(), + sprout::slot_detail::counter(sprout::true_type(), sprout::slot_detail::tag()), K, Value >::value > diff --git a/sprout/stateful/typed_id.hpp b/sprout/stateful/typed_id.hpp index 8ecce981..39efda9c 100644 --- a/sprout/stateful/typed_id.hpp +++ b/sprout/stateful/typed_id.hpp @@ -47,33 +47,33 @@ namespace sprout { }; template())> - static SPROUT_CONSTEXPR bool check_impl(int, tag) { + static SPROUT_CONSTEXPR bool check(int, tag) { return true; } template - static SPROUT_CONSTEXPR bool check_impl(long, tag) { + static SPROUT_CONSTEXPR bool check(long, tag) { return false; } template - static SPROUT_CONSTEXPR bool check(bool R = check_impl(0, tag())) { + static SPROUT_CONSTEXPR bool check(bool R = check(0, tag())) { return R; } template - static SPROUT_CONSTEXPR int counter_impl(sprout::false_type, tag) { + static SPROUT_CONSTEXPR int counter(sprout::false_type, tag) { return 0; } template - static SPROUT_CONSTEXPR int counter_impl( + static SPROUT_CONSTEXPR int counter( sprout::true_type, tag, int R = !check() ? N - : counter_impl(sprout::bool_constant()>(), tag()) + : counter(sprout::bool_constant()>(), tag()) ) { return R; } template - static SPROUT_CONSTEXPR int counter(int R = counter_impl(sprout::true_type(), tag())) { + static SPROUT_CONSTEXPR int counter(int R = counter(sprout::true_type(), tag())) { return R; } diff --git a/sprout/stateful/typed_slot.hpp b/sprout/stateful/typed_slot.hpp index 0765abdc..a6746427 100644 --- a/sprout/stateful/typed_slot.hpp +++ b/sprout/stateful/typed_slot.hpp @@ -93,33 +93,33 @@ namespace sprout { }; template())> - SPROUT_CONSTEXPR bool check_impl(int, sprout::typed_slot_detail::tag) { + SPROUT_CONSTEXPR bool check(int, sprout::typed_slot_detail::tag) { return true; } template - SPROUT_CONSTEXPR bool check_impl(long, sprout::typed_slot_detail::tag) { + SPROUT_CONSTEXPR bool check(long, sprout::typed_slot_detail::tag) { return false; } template - SPROUT_CONSTEXPR bool check(bool R = sprout::typed_slot_detail::check_impl(0, sprout::typed_slot_detail::tag())) { + SPROUT_CONSTEXPR bool check(bool R = sprout::typed_slot_detail::check(0, sprout::typed_slot_detail::tag())) { return R; } template - SPROUT_CONSTEXPR int counter_impl(sprout::false_type, sprout::typed_slot_detail::tag) { + SPROUT_CONSTEXPR int counter(sprout::false_type, sprout::typed_slot_detail::tag) { return 0; } template - SPROUT_CONSTEXPR int counter_impl( + SPROUT_CONSTEXPR int counter( sprout::true_type, sprout::typed_slot_detail::tag, - int R = !sprout::typed_slot_detail::check() ? N - : counter_impl(sprout::bool_constant()>(), sprout::typed_slot_detail::tag()) + int R = !sprout::typed_slot_detail::check(0, sprout::typed_slot_detail::tag()) ? N + : counter(sprout::bool_constant())>(), sprout::typed_slot_detail::tag()) ) { return R; } template - SPROUT_CONSTEXPR int counter(int R = sprout::typed_slot_detail::counter_impl(sprout::true_type(), sprout::typed_slot_detail::tag())) { + SPROUT_CONSTEXPR int counter(int R = sprout::typed_slot_detail::counter(sprout::true_type(), sprout::typed_slot_detail::tag())) { return R; } @@ -130,8 +130,8 @@ namespace sprout { template SPROUT_CONSTEXPR std::intmax_t get_impl( sprout::true_type, sprout::typed_slot_detail::tag, - std::intmax_t R = !sprout::typed_slot_detail::check() ? adl_get(sprout::typed_slot_detail::tag(), sprout::integral_constant()) - : get_impl(sprout::bool_constant()>(), sprout::typed_slot_detail::tag()) + std::intmax_t R = !sprout::typed_slot_detail::check(0, sprout::typed_slot_detail::tag()) ? adl_get(sprout::typed_slot_detail::tag(), sprout::integral_constant()) + : get_impl(sprout::bool_constant())>(), sprout::typed_slot_detail::tag()) ) { return R; @@ -156,19 +156,19 @@ namespace sprout { // assign_slot_return // template< - typename T, - std::intmax_t Value, + typename T, std::intmax_t Value, + int N = 0, 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()), sprout::typed_id::value, Value >::value > SPROUT_CXX14_CONSTEXPR void assign_slot() {} template< - typename T, - std::intmax_t Value, + typename T, std::intmax_t Value, + int N = 0, 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()), sprout::typed_id::value, Value >::value >