From fa619fc1bfb8b615787d073a33caa61297a65762 Mon Sep 17 00:00:00 2001 From: bolero-MURAKAMI Date: Sun, 17 May 2015 08:52:34 +0900 Subject: [PATCH] add component for stateful lib --- sprout/stateful.hpp | 2 + sprout/stateful/counter.hpp | 69 +++++-------- sprout/stateful/rand.hpp | 98 +++++++++++------- sprout/stateful/slot.hpp | 102 +++++++++--------- sprout/stateful/typed_id.hpp | 104 +++++++++++++++++++ sprout/stateful/typed_slot.hpp | 182 +++++++++++++++++++++++++++++++++ 6 files changed, 426 insertions(+), 131 deletions(-) create mode 100644 sprout/stateful/typed_id.hpp create mode 100644 sprout/stateful/typed_slot.hpp diff --git a/sprout/stateful.hpp b/sprout/stateful.hpp index c43aca5b..6a9213cb 100644 --- a/sprout/stateful.hpp +++ b/sprout/stateful.hpp @@ -12,5 +12,7 @@ #include #include #include +#include +#include #endif // #ifndef SPROUT_STATEFUL_HPP diff --git a/sprout/stateful/counter.hpp b/sprout/stateful/counter.hpp index 47c3f42d..46848d80 100644 --- a/sprout/stateful/counter.hpp +++ b/sprout/stateful/counter.hpp @@ -9,15 +9,11 @@ #define SPROUT_STATEFUL_COUNTER_HPP #include -#include +#include namespace sprout { #ifndef SPROUT_CONFIG_DISABLE_CONSTEXPR - namespace detail { - SPROUT_STATIC_CONSTEXPR std::size_t counter_default_call_limit = 128; - } // namespace detail - namespace counter_detail { #if defined(__GNUC__) && !defined(__clang__) # pragma GCC diagnostic push @@ -43,63 +39,54 @@ namespace sprout { friend SPROUT_CONSTEXPR int adl_counter(sprout::counter_detail::tag) { return N; } - SPROUT_STATIC_CONSTEXPR int value = N - 1; + SPROUT_STATIC_CONSTEXPR int value = N; }; template SPROUT_CONSTEXPR_OR_CONST int sprout::counter_detail::state::value; - template<> - struct state<1> { - friend SPROUT_CONSTEXPR int adl_counter(sprout::counter_detail::tag<1>) { - return 1; - } - static SPROUT_CONSTEXPR int value = 0; - }; - SPROUT_CONSTEXPR_OR_CONST int sprout::counter_detail::state<1>::value; - template())> - SPROUT_CONSTEXPR int counter( - int, sprout::counter_detail::tag + template())> + SPROUT_CONSTEXPR bool check_impl(int, sprout::counter_detail::tag) { + return true; + } + template + SPROUT_CONSTEXPR bool check_impl(long, sprout::counter_detail::tag) { + return false; + } + template + SPROUT_CONSTEXPR bool check(bool R = sprout::counter_detail::check_impl(0, sprout::counter_detail::tag())) { + return R; + } + + template + SPROUT_CONSTEXPR int counter_impl(sprout::false_type, sprout::counter_detail::tag) { + return 0; + } + template + SPROUT_CONSTEXPR int counter_impl( + sprout::true_type, sprout::counter_detail::tag, + int R = !sprout::counter_detail::check() ? N + : counter_impl(sprout::bool_constant()>(), sprout::counter_detail::tag()) ) { return R; } - SPROUT_CONSTEXPR int counter( - long, sprout::counter_detail::tag<0> - ) - { - return 0; - } - template - SPROUT_CONSTEXPR int counter( - long, sprout::counter_detail::tag, - int R = counter(0, sprout::counter_detail::tag()) - ) - { + template + SPROUT_CONSTEXPR int counter(int R = sprout::counter_detail::counter_impl(sprout::true_type(), sprout::counter_detail::tag())) { return R; } } // namespace counter_detail // // counter - // counter_before // template< - std::size_t Limit = sprout::detail::counter_default_call_limit, + int N = 1, int R = sprout::counter_detail::state< - sprout::counter_detail::counter(0, sprout::counter_detail::tag()) + 1 + sprout::counter_detail::counter() + N - 1 >::value > SPROUT_CONSTEXPR int counter() { return R; } - template< - std::size_t Limit = sprout::detail::counter_default_call_limit, - int R = sprout::counter_detail::state< - sprout::counter_detail::counter(0, sprout::counter_detail::tag()) - >::value - > - SPROUT_CONSTEXPR int counter_before() { - return R; - } #endif } // namespace sprout diff --git a/sprout/stateful/rand.hpp b/sprout/stateful/rand.hpp index dc2b19a5..3e9541d0 100644 --- a/sprout/stateful/rand.hpp +++ b/sprout/stateful/rand.hpp @@ -15,6 +15,7 @@ #include #include #include +#include #include namespace sprout { @@ -29,7 +30,6 @@ namespace sprout { > rand_result_type; SPROUT_STATIC_CONSTEXPR std::size_t rand_default_seed = SPROUT_UNIQUE_SEED; - SPROUT_STATIC_CONSTEXPR std::size_t rand_default_call_limit = 128; } // namespace detail namespace rand_detail { @@ -68,7 +68,8 @@ namespace sprout { // generate a next random number SPROUT_STATIC_CONSTEXPR sprout::detail::rand_result_type result SPROUT_STATIC_CONSTEXPR_DATA_MEMBER_INNER(( - !IsSrand ? sprout::rand_detail::state< + !IsSrand + ? sprout::rand_detail::state< N - 1, adl_is_srand(sprout::rand_detail::tag()), adl_seed(sprout::rand_detail::tag()) @@ -85,7 +86,8 @@ namespace sprout { template SPROUT_CONSTEXPR_OR_CONST sprout::detail::rand_result_type sprout::rand_detail::state::result SPROUT_STATIC_CONSTEXPR_DATA_MEMBER_OUTER(( - !IsSrand ? sprout::rand_detail::state< + !IsSrand + ? sprout::rand_detail::state< N - 1, adl_is_srand(sprout::rand_detail::tag()), adl_seed(sprout::rand_detail::tag()) @@ -100,65 +102,85 @@ namespace sprout { template SPROUT_CONSTEXPR_OR_CONST int sprout::rand_detail::state::value; template - struct state<1, IsSrand, Seed> { - friend SPROUT_CONSTEXPR int adl_counter(sprout::rand_detail::tag<1>) { - return 1; + struct state<0, IsSrand, Seed> { + friend SPROUT_CONSTEXPR int adl_counter(sprout::rand_detail::tag<0>) { + return 0; } - friend SPROUT_CONSTEXPR bool adl_is_srand(sprout::rand_detail::tag<1>) { + friend SPROUT_CONSTEXPR bool adl_is_srand(sprout::rand_detail::tag<0>) { return IsSrand; } - friend SPROUT_CONSTEXPR unsigned adl_seed(sprout::rand_detail::tag<1>) { + friend SPROUT_CONSTEXPR unsigned adl_seed(sprout::rand_detail::tag<0>) { return Seed; } // generate a first random number between [0, RAND_MAX] SPROUT_STATIC_CONSTEXPR sprout::detail::rand_result_type result - SPROUT_STATIC_CONSTEXPR_DATA_MEMBER_INNER( - sprout::detail::rand_distribution_type(0, RAND_MAX) - (sprout::as_const(sprout::detail::rand_generator_type(!IsSrand ? sprout::detail::rand_default_seed : Seed))) - ) + SPROUT_STATIC_CONSTEXPR_DATA_MEMBER_INNER(( + !IsSrand + ? sprout::detail::rand_distribution_type(0, RAND_MAX) + (sprout::as_const(sprout::detail::rand_generator_type(!IsSrand ? sprout::detail::rand_default_seed : Seed))) + : sprout::detail::rand_result_type( + Seed, + sprout::detail::rand_generator_type(Seed), + sprout::detail::rand_distribution_type(0, RAND_MAX) + ) + )) ; static SPROUT_CONSTEXPR int value = result; }; template - SPROUT_CONSTEXPR_OR_CONST sprout::detail::rand_result_type sprout::rand_detail::state<1, IsSrand, Seed>::result + SPROUT_CONSTEXPR_OR_CONST sprout::detail::rand_result_type sprout::rand_detail::state<0, IsSrand, Seed>::result SPROUT_STATIC_CONSTEXPR_DATA_MEMBER_OUTER( - sprout::detail::rand_distribution_type(0, RAND_MAX) - (sprout::as_const(sprout::detail::rand_generator_type(!IsSrand ? sprout::detail::rand_default_seed : Seed))) + !IsSrand + ? sprout::detail::rand_distribution_type(0, RAND_MAX) + (sprout::as_const(sprout::detail::rand_generator_type(!IsSrand ? sprout::detail::rand_default_seed : Seed))) + : sprout::detail::rand_result_type( + Seed, + sprout::detail::rand_generator_type(Seed), + sprout::detail::rand_distribution_type(0, RAND_MAX) + ) ) ; template - SPROUT_CONSTEXPR_OR_CONST int sprout::rand_detail::state<1, IsSrand, Seed>::value; + SPROUT_CONSTEXPR_OR_CONST int sprout::rand_detail::state<0, IsSrand, Seed>::value; - template())> - SPROUT_CONSTEXPR int counter( - int, sprout::rand_detail::tag + template())> + SPROUT_CONSTEXPR bool check_impl(int, sprout::rand_detail::tag) { + return true; + } + template + SPROUT_CONSTEXPR bool check_impl(long, sprout::rand_detail::tag) { + return false; + } + template + SPROUT_CONSTEXPR bool check(bool R = sprout::rand_detail::check_impl(0, sprout::rand_detail::tag())) { + return R; + } + + template + SPROUT_CONSTEXPR int counter_impl(sprout::false_type, sprout::rand_detail::tag) { + return 0; + } + template + SPROUT_CONSTEXPR int counter_impl( + sprout::true_type, sprout::rand_detail::tag, + int R = !sprout::rand_detail::check() ? N + : counter_impl(sprout::bool_constant()>(), sprout::rand_detail::tag()) ) { return R; } - SPROUT_CONSTEXPR int counter( - long, sprout::rand_detail::tag<0> - ) - { - return 0; - } - template - SPROUT_CONSTEXPR int counter( - long, sprout::rand_detail::tag, - int R = counter(0, sprout::rand_detail::tag()) - ) - { + template + SPROUT_CONSTEXPR int counter(int R = sprout::rand_detail::counter_impl(sprout::true_type(), sprout::rand_detail::tag())) { return R; } } // namespace rand_detail // // rand - // rand_before // template< - std::size_t Limit = sprout::detail::rand_default_call_limit, + int N = 1, int R = sprout::rand_detail::state< - sprout::rand_detail::counter(0, sprout::rand_detail::tag()) + 1 + sprout::rand_detail::counter() + N - 1 >::value > SPROUT_CONSTEXPR int rand() { @@ -171,18 +193,18 @@ namespace sprout { // template< unsigned Seed, - std::size_t Limit = sprout::detail::rand_default_call_limit, + int N = 1, int = sprout::rand_detail::state< - sprout::rand_detail::counter(0, sprout::rand_detail::tag()) + 1, + sprout::rand_detail::counter() + N - 1, true, Seed >::value > SPROUT_CXX14_CONSTEXPR void srand() {} template< unsigned Seed, - std::size_t Limit = sprout::detail::rand_default_call_limit, + int N = 1, int R = sprout::rand_detail::state< - sprout::rand_detail::counter(0, sprout::rand_detail::tag()) + 1, + sprout::rand_detail::counter() + N - 1, true, Seed >::value > diff --git a/sprout/stateful/slot.hpp b/sprout/stateful/slot.hpp index c847b365..87a60e45 100644 --- a/sprout/stateful/slot.hpp +++ b/sprout/stateful/slot.hpp @@ -10,17 +10,12 @@ #include #include -#include #include #include namespace sprout { #ifndef SPROUT_CONFIG_DISABLE_CONSTEXPR - namespace detail { - SPROUT_STATIC_CONSTEXPR std::size_t slot_default_call_limit = 128; - } // namespace detail - namespace slot_detail { #if defined(__GNUC__) && !defined(__clang__) # pragma GCC diagnostic push @@ -46,7 +41,9 @@ namespace sprout { #endif template - struct state { + struct state + : public sprout::integral_constant + { friend SPROUT_CONSTEXPR int adl_counter(sprout::slot_detail::tag) { return N; } @@ -72,18 +69,20 @@ namespace sprout { } }; template - struct state<1, Key, Value> { - friend SPROUT_CONSTEXPR int adl_counter(sprout::slot_detail::tag<1>) { - return 1; + struct state<0, Key, Value> + : public sprout::integral_constant + { + friend SPROUT_CONSTEXPR int adl_counter(sprout::slot_detail::tag<0>) { + return 0; } - friend SPROUT_CONSTEXPR int adl_key(sprout::slot_detail::tag<1>) { + friend SPROUT_CONSTEXPR int adl_key(sprout::slot_detail::tag<0>) { return Key; } - friend SPROUT_CONSTEXPR std::intmax_t adl_value(sprout::slot_detail::tag<1>) { + friend SPROUT_CONSTEXPR std::intmax_t adl_value(sprout::slot_detail::tag<0>) { return Value; } template - friend SPROUT_CONSTEXPR std::intmax_t adl_get(sprout::slot_detail::tag<1>, sprout::integral_constant) { + friend SPROUT_CONSTEXPR std::intmax_t adl_get(sprout::slot_detail::tag<0>, sprout::integral_constant) { return get(); } template @@ -92,58 +91,61 @@ namespace sprout { } }; - template())> - SPROUT_CONSTEXPR int counter( - int, sprout::slot_detail::tag - ) - { - return R; - } - SPROUT_CONSTEXPR int counter( - long, sprout::slot_detail::tag<0> - ) - { - return 0; + template())> + SPROUT_CONSTEXPR bool check_impl(int, sprout::slot_detail::tag) { + return true; } template - SPROUT_CONSTEXPR int counter( - long, sprout::slot_detail::tag, - int R = counter(0, sprout::slot_detail::tag()) - ) - { + SPROUT_CONSTEXPR bool check_impl(long, sprout::slot_detail::tag) { + return false; + } + template + SPROUT_CONSTEXPR bool check(bool R = sprout::slot_detail::check_impl(0, sprout::slot_detail::tag())) { return R; } - template(), sprout::integral_constant())> - SPROUT_CONSTEXPR std::intmax_t get( - int, sprout::slot_detail::tag + template + SPROUT_CONSTEXPR int counter_impl(sprout::false_type, sprout::slot_detail::tag) { + return 0; + } + template + SPROUT_CONSTEXPR int counter_impl( + 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()) ) { return R; } - template - SPROUT_CONSTEXPR std::intmax_t get( - long, sprout::slot_detail::tag<0> - ) - { + template + SPROUT_CONSTEXPR int counter(int R = sprout::slot_detail::counter_impl(sprout::true_type(), sprout::slot_detail::tag())) { + return R; + } + + template + SPROUT_CONSTEXPR std::intmax_t get_impl(sprout::false_type, sprout::slot_detail::tag) { return 0; } template - SPROUT_CONSTEXPR std::intmax_t get( - long, sprout::slot_detail::tag, - std::intmax_t R = get(0, sprout::slot_detail::tag()) + SPROUT_CONSTEXPR std::intmax_t get_impl( + sprout::true_type, sprout::slot_detail::tag, + std::intmax_t R = !sprout::slot_detail::check() ? adl_get(sprout::slot_detail::tag(), sprout::integral_constant()) + : get_impl(sprout::bool_constant()>(), sprout::slot_detail::tag()) ) { return R; } + template + SPROUT_CONSTEXPR std::intmax_t get(int R = sprout::slot_detail::get_impl(sprout::true_type(), sprout::slot_detail::tag())) { + return R; + } } // namespace slot_detail // // slot // template< int K, - std::size_t Limit = sprout::detail::slot_default_call_limit, - std::intmax_t R = sprout::slot_detail::get(0, sprout::slot_detail::tag()) + std::intmax_t R = sprout::slot_detail::get() > SPROUT_CONSTEXPR std::intmax_t slot() { return R; @@ -153,23 +155,19 @@ namespace sprout { // assign_slot_return // template< - int K, - std::intmax_t Value, - std::size_t Limit = sprout::detail::slot_default_call_limit, + int K, std::intmax_t Value, std::intmax_t = sprout::slot_detail::state< - sprout::slot_detail::counter(0, sprout::slot_detail::tag()) + 1, + sprout::slot_detail::counter(), K, Value - >::template get() + >::value > SPROUT_CXX14_CONSTEXPR void assign_slot() {} template< - int K, - std::intmax_t Value, - std::size_t Limit = sprout::detail::slot_default_call_limit, + int K, std::intmax_t Value, std::intmax_t R = sprout::slot_detail::state< - sprout::slot_detail::counter(0, sprout::slot_detail::tag()) + 1, + sprout::slot_detail::counter(), K, Value - >::template get() + >::value > SPROUT_CONSTEXPR std::intmax_t assign_slot_return() { return R; diff --git a/sprout/stateful/typed_id.hpp b/sprout/stateful/typed_id.hpp new file mode 100644 index 00000000..8ecce981 --- /dev/null +++ b/sprout/stateful/typed_id.hpp @@ -0,0 +1,104 @@ +/*============================================================================= + Copyright (c) 2011-2015 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + 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) +=============================================================================*/ +#ifndef SPROUT_STATEFUL_TYPED_ID_HPP +#define SPROUT_STATEFUL_TYPED_ID_HPP + +#include +#include +#include + +namespace sprout { +#ifndef SPROUT_CONFIG_DISABLE_CONSTEXPR + + namespace typed_id_detail { + template + struct typed { +#if defined(__GNUC__) && !defined(__clang__) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wnon-template-friend" +#endif +#if defined(__clang__) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wundefined-inline" +#endif + template + struct tag { + friend SPROUT_CONSTEXPR int adl_counter(tag); + }; +#if defined(__clang__) +# pragma clang diagnostic pop +#endif +#if defined(__GNUC__) && !defined(__clang__) +# pragma GCC diagnostic pop +#endif + + template + struct state + : public sprout::integral_constant + { + friend SPROUT_CONSTEXPR int adl_counter(tag) { + return N; + } + }; + + template())> + static SPROUT_CONSTEXPR bool check_impl(int, tag) { + return true; + } + template + static SPROUT_CONSTEXPR bool check_impl(long, tag) { + return false; + } + template + static SPROUT_CONSTEXPR bool check(bool R = check_impl(0, tag())) { + return R; + } + + template + static SPROUT_CONSTEXPR int counter_impl(sprout::false_type, tag) { + return 0; + } + template + static SPROUT_CONSTEXPR int counter_impl( + sprout::true_type, tag, + int R = !check() ? N + : counter_impl(sprout::bool_constant()>(), tag()) + ) + { + return R; + } + template + static SPROUT_CONSTEXPR int counter(int R = counter_impl(sprout::true_type(), tag())) { + return R; + } + + template + static SPROUT_CONSTEXPR int id(int R = state::value) { + return R; + } + }; + + template + struct depends_on + : public sprout::identity + {}; + } // namespace typed_id_detail + // + // typed_id + // + template + struct typed_id + : public sprout::integral_constant< + int, sprout::typed_id_detail::typed::type>::id() + > + {}; + +#endif +} // namespace sprout + +#endif // #ifndef SPROUT_STATEFUL_TYPED_ID_HPP diff --git a/sprout/stateful/typed_slot.hpp b/sprout/stateful/typed_slot.hpp new file mode 100644 index 00000000..0765abdc --- /dev/null +++ b/sprout/stateful/typed_slot.hpp @@ -0,0 +1,182 @@ +/*============================================================================= + Copyright (c) 2011-2015 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + 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) +=============================================================================*/ +#ifndef SPROUT_STATEFUL_TYPED_SLOT_HPP +#define SPROUT_STATEFUL_TYPED_SLOT_HPP + +#include +#include +#include +#include +#include + +namespace sprout { +#ifndef SPROUT_CONFIG_DISABLE_CONSTEXPR + + namespace typed_slot_detail { +#if defined(__GNUC__) && !defined(__clang__) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wnon-template-friend" +#endif +#if defined(__clang__) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wundefined-inline" +#endif + template + struct tag { + friend SPROUT_CONSTEXPR int adl_counter(sprout::typed_slot_detail::tag); + friend SPROUT_CONSTEXPR int adl_key(sprout::typed_slot_detail::tag); + friend SPROUT_CONSTEXPR std::intmax_t adl_value(sprout::typed_slot_detail::tag); + template + friend SPROUT_CONSTEXPR std::intmax_t adl_get(sprout::typed_slot_detail::tag, sprout::integral_constant); + }; +#if defined(__clang__) +# pragma clang diagnostic pop +#endif +#if defined(__GNUC__) && !defined(__clang__) +# pragma GCC diagnostic pop +#endif + + template + struct state + : public sprout::integral_constant + { + friend SPROUT_CONSTEXPR int adl_counter(sprout::typed_slot_detail::tag) { + return N; + } + friend SPROUT_CONSTEXPR int adl_key(sprout::typed_slot_detail::tag) { + return Key; + } + friend SPROUT_CONSTEXPR std::intmax_t adl_value(sprout::typed_slot_detail::tag) { + return Value; + } + template + friend SPROUT_CONSTEXPR std::intmax_t adl_get(sprout::typed_slot_detail::tag, sprout::integral_constant) { + return get(); + } + template + static SPROUT_CONSTEXPR std::intmax_t get() { + return K == Key ? Value + : state< + N - 1, + adl_key(sprout::typed_slot_detail::tag()), + adl_value(sprout::typed_slot_detail::tag()) + >::template get() + ; + } + }; + template + struct state<0, Key, Value> + : public sprout::integral_constant + { + friend SPROUT_CONSTEXPR int adl_counter(sprout::typed_slot_detail::tag<0>) { + return 0; + } + friend SPROUT_CONSTEXPR int adl_key(sprout::typed_slot_detail::tag<0>) { + return Key; + } + friend SPROUT_CONSTEXPR std::intmax_t adl_value(sprout::typed_slot_detail::tag<0>) { + return Value; + } + template + friend SPROUT_CONSTEXPR std::intmax_t adl_get(sprout::typed_slot_detail::tag<0>, sprout::integral_constant) { + return get(); + } + template + static SPROUT_CONSTEXPR std::intmax_t get() { + return SPROUT_ASSERT(K == Key), Value; + } + }; + + template())> + SPROUT_CONSTEXPR bool check_impl(int, sprout::typed_slot_detail::tag) { + return true; + } + template + SPROUT_CONSTEXPR bool check_impl(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())) { + return R; + } + + template + SPROUT_CONSTEXPR int counter_impl(sprout::false_type, sprout::typed_slot_detail::tag) { + return 0; + } + template + SPROUT_CONSTEXPR int counter_impl( + 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()) + ) + { + return R; + } + template + SPROUT_CONSTEXPR int counter(int R = sprout::typed_slot_detail::counter_impl(sprout::true_type(), sprout::typed_slot_detail::tag())) { + return R; + } + + template + SPROUT_CONSTEXPR std::intmax_t get_impl(sprout::false_type, sprout::typed_slot_detail::tag) { + return 0; + } + 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()) + ) + { + return R; + } + template + SPROUT_CONSTEXPR std::intmax_t get(int R = sprout::typed_slot_detail::get_impl(sprout::true_type(), sprout::typed_slot_detail::tag())) { + return R; + } + } // namespace typed_slot_detail + // + // slot + // + template< + typename T, + std::intmax_t R = sprout::typed_slot_detail::get::value>() + > + SPROUT_CONSTEXPR std::intmax_t slot() { + return R; + } + // + // assign_slot + // assign_slot_return + // + template< + typename T, + std::intmax_t Value, + std::intmax_t = sprout::typed_slot_detail::state< + sprout::typed_slot_detail::counter(), + sprout::typed_id::value, Value + >::value + > + SPROUT_CXX14_CONSTEXPR void assign_slot() {} + template< + typename T, + std::intmax_t Value, + std::intmax_t R = sprout::typed_slot_detail::state< + sprout::typed_slot_detail::counter(), + sprout::typed_id::value, Value + >::value + > + SPROUT_CONSTEXPR std::intmax_t assign_slot_return() { + return R; + } + +#endif +} // namespace sprout + +#endif // #ifndef SPROUT_STATEFUL_TYPED_SLOT_HPP