mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2024-11-14 10:39:05 +00:00
add utility any_convertible
This commit is contained in:
parent
a9ab69df0a
commit
926facbb83
6 changed files with 71 additions and 63 deletions
|
@ -7,7 +7,6 @@
|
|||
#include <sprout/array.hpp>
|
||||
#include <sprout/cstdlib/abs.hpp>
|
||||
#ifdef SPROUT_WORKAROUND_NOT_TERMINATE_RECURSIVE_CONSTEXPR_FUNCTION_TEMPLATE
|
||||
# include <stdexcept>
|
||||
# include <sprout/workaround/recursive_function_template.hpp>
|
||||
#endif
|
||||
|
||||
|
@ -52,9 +51,7 @@ namespace sprout {
|
|||
template<int D, typename BuiltInUnsigned, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_BREAK(D)>
|
||||
inline SPROUT_CONSTEXPR BuiltInUnsigned
|
||||
gcd_binary_2_2(unsigned shifts, sprout::array<BuiltInUnsigned, 2> const& r, unsigned which) {
|
||||
return throw std::runtime_error(SPROUT_RECURSIVE_FUNCTION_TEMPLATE_INSTANTIATION_EXCEEDED_MESSAGE),
|
||||
BuiltInUnsigned()
|
||||
;
|
||||
return sprout::throw_recursive_function_template_instantiation_exeeded();
|
||||
}
|
||||
template<int D, typename BuiltInUnsigned, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_CONTINUE_DECL(D)>
|
||||
inline SPROUT_CONSTEXPR BuiltInUnsigned
|
||||
|
@ -85,9 +82,7 @@ namespace sprout {
|
|||
template<int D, typename BuiltInUnsigned, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_BREAK_DECL(D)>
|
||||
inline SPROUT_CONSTEXPR BuiltInUnsigned
|
||||
gcd_binary_2_1(unsigned shifts, sprout::array<BuiltInUnsigned, 2> const& r, unsigned which) {
|
||||
return throw std::runtime_error(SPROUT_RECURSIVE_FUNCTION_TEMPLATE_INSTANTIATION_EXCEEDED_MESSAGE),
|
||||
BuiltInUnsigned()
|
||||
;
|
||||
return sprout::throw_recursive_function_template_instantiation_exeeded();
|
||||
}
|
||||
#else
|
||||
template<typename BuiltInUnsigned>
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
#include <sprout/random/random_result.hpp>
|
||||
#include <sprout/random/uniform_01.hpp>
|
||||
#ifdef SPROUT_WORKAROUND_NOT_TERMINATE_RECURSIVE_CONSTEXPR_FUNCTION_TEMPLATE
|
||||
# include <stdexcept>
|
||||
# include <sprout/workaround/recursive_function_template.hpp>
|
||||
#endif
|
||||
|
||||
|
@ -273,9 +272,7 @@ namespace sprout {
|
|||
template<int D, typename Engine, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_BREAK(D)>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, binomial_distribution>
|
||||
generate_10(Engine const& eng, RealType v, IntType k, IntType nm, RealType h, IntType nk) const {
|
||||
return throw std::runtime_error(SPROUT_RECURSIVE_FUNCTION_TEMPLATE_INSTANTIATION_EXCEEDED_MESSAGE),
|
||||
sprout::random::random_result<Engine, binomial_distribution>()
|
||||
;
|
||||
return sprout::throw_recursive_function_template_instantiation_exeeded();
|
||||
}
|
||||
template<int D, typename Engine, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_CONTINUE(D)>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, binomial_distribution>
|
||||
|
@ -287,9 +284,7 @@ namespace sprout {
|
|||
template<int D, typename Engine, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_BREAK(D)>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, binomial_distribution>
|
||||
generate_9(Engine const& eng, RealType v, IntType k, IntType nm) const {
|
||||
return throw std::runtime_error(SPROUT_RECURSIVE_FUNCTION_TEMPLATE_INSTANTIATION_EXCEEDED_MESSAGE),
|
||||
sprout::random::random_result<Engine, binomial_distribution>()
|
||||
;
|
||||
return sprout::throw_recursive_function_template_instantiation_exeeded();
|
||||
}
|
||||
template<int D, typename Engine, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_CONTINUE(D)>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, binomial_distribution>
|
||||
|
@ -302,9 +297,7 @@ namespace sprout {
|
|||
template<int D, typename Engine, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_BREAK(D)>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, binomial_distribution>
|
||||
generate_8(Engine const& eng, RealType v, IntType k, RealType rho, RealType t) const {
|
||||
return throw std::runtime_error(SPROUT_RECURSIVE_FUNCTION_TEMPLATE_INSTANTIATION_EXCEEDED_MESSAGE),
|
||||
sprout::random::random_result<Engine, binomial_distribution>()
|
||||
;
|
||||
return sprout::throw_recursive_function_template_instantiation_exeeded();
|
||||
}
|
||||
template<int D, typename Engine, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_CONTINUE(D)>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, binomial_distribution>
|
||||
|
@ -317,9 +310,7 @@ namespace sprout {
|
|||
template<int D, typename Engine, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_BREAK(D)>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, binomial_distribution>
|
||||
generate_7_3(Engine const& eng, RealType v, IntType k, RealType f) const {
|
||||
return throw std::runtime_error(SPROUT_RECURSIVE_FUNCTION_TEMPLATE_INSTANTIATION_EXCEEDED_MESSAGE),
|
||||
sprout::random::random_result<Engine, binomial_distribution>()
|
||||
;
|
||||
return sprout::throw_recursive_function_template_instantiation_exeeded();
|
||||
}
|
||||
template<int D, typename Engine, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_CONTINUE(D)>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, binomial_distribution>
|
||||
|
@ -332,9 +323,7 @@ namespace sprout {
|
|||
template<int D, typename Engine, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_BREAK(D)>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, binomial_distribution>
|
||||
generate_7_2(Engine const& eng, RealType v, IntType k, RealType f, IntType i) const {
|
||||
return throw std::runtime_error(SPROUT_RECURSIVE_FUNCTION_TEMPLATE_INSTANTIATION_EXCEEDED_MESSAGE),
|
||||
sprout::random::random_result<Engine, binomial_distribution>()
|
||||
;
|
||||
return sprout::throw_recursive_function_template_instantiation_exeeded();
|
||||
}
|
||||
template<int D, typename Engine, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_CONTINUE(D)>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, binomial_distribution>
|
||||
|
@ -347,9 +336,7 @@ namespace sprout {
|
|||
template<int D, typename Engine, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_BREAK(D)>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, binomial_distribution>
|
||||
generate_7_1(Engine const& eng, RealType v, IntType k, RealType f, IntType i) const {
|
||||
return throw std::runtime_error(SPROUT_RECURSIVE_FUNCTION_TEMPLATE_INSTANTIATION_EXCEEDED_MESSAGE),
|
||||
sprout::random::random_result<Engine, binomial_distribution>()
|
||||
;
|
||||
return sprout::throw_recursive_function_template_instantiation_exeeded();
|
||||
}
|
||||
template<int D, typename Engine, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_CONTINUE(D)>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, binomial_distribution>
|
||||
|
@ -362,9 +349,7 @@ namespace sprout {
|
|||
template<int D, typename Engine, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_BREAK(D)>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, binomial_distribution>
|
||||
generate_7(Engine const& eng, RealType v, IntType k, RealType f = RealType(1)) const {
|
||||
return throw std::runtime_error(SPROUT_RECURSIVE_FUNCTION_TEMPLATE_INSTANTIATION_EXCEEDED_MESSAGE),
|
||||
sprout::random::random_result<Engine, binomial_distribution>()
|
||||
;
|
||||
return sprout::throw_recursive_function_template_instantiation_exeeded();
|
||||
}
|
||||
template<int D, typename Engine, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_CONTINUE(D)>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, binomial_distribution>
|
||||
|
@ -380,9 +365,7 @@ namespace sprout {
|
|||
template<int D, typename Engine, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_BREAK(D)>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, binomial_distribution>
|
||||
generate_6(Engine const& eng, RealType v, IntType k, RealType km) const {
|
||||
return throw std::runtime_error(SPROUT_RECURSIVE_FUNCTION_TEMPLATE_INSTANTIATION_EXCEEDED_MESSAGE),
|
||||
sprout::random::random_result<Engine, binomial_distribution>()
|
||||
;
|
||||
return sprout::throw_recursive_function_template_instantiation_exeeded();
|
||||
}
|
||||
template<int D, typename Engine, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_CONTINUE(D)>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, binomial_distribution>
|
||||
|
@ -395,9 +378,7 @@ namespace sprout {
|
|||
template<int D, typename Engine, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_BREAK(D)>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, binomial_distribution>
|
||||
generate_5(Engine const& eng, RealType v, RealType u, RealType us, IntType k) const {
|
||||
return throw std::runtime_error(SPROUT_RECURSIVE_FUNCTION_TEMPLATE_INSTANTIATION_EXCEEDED_MESSAGE),
|
||||
sprout::random::random_result<Engine, binomial_distribution>()
|
||||
;
|
||||
return sprout::throw_recursive_function_template_instantiation_exeeded();
|
||||
}
|
||||
template<int D, typename Engine, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_CONTINUE(D)>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, binomial_distribution>
|
||||
|
@ -407,9 +388,7 @@ namespace sprout {
|
|||
template<int D, typename Engine, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_BREAK(D)>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, binomial_distribution>
|
||||
generate_4(Engine const& eng, RealType v, RealType u, RealType us) const {
|
||||
return throw std::runtime_error(SPROUT_RECURSIVE_FUNCTION_TEMPLATE_INSTANTIATION_EXCEEDED_MESSAGE),
|
||||
sprout::random::random_result<Engine, binomial_distribution>()
|
||||
;
|
||||
return sprout::throw_recursive_function_template_instantiation_exeeded();
|
||||
}
|
||||
template<int D, typename Engine, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_CONTINUE(D)>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, binomial_distribution>
|
||||
|
@ -419,9 +398,7 @@ namespace sprout {
|
|||
template<int D, typename Engine, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_BREAK(D)>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, binomial_distribution>
|
||||
generate_3(Engine const& eng, RealType v, RealType u) const {
|
||||
return throw std::runtime_error(SPROUT_RECURSIVE_FUNCTION_TEMPLATE_INSTANTIATION_EXCEEDED_MESSAGE),
|
||||
sprout::random::random_result<Engine, binomial_distribution>()
|
||||
;
|
||||
return sprout::throw_recursive_function_template_instantiation_exeeded();
|
||||
}
|
||||
template<int D, typename Engine, typename Random, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_CONTINUE(D)>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, binomial_distribution>
|
||||
|
@ -440,9 +417,7 @@ namespace sprout {
|
|||
template<int D, typename Engine, typename Random, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_BREAK(D)>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, binomial_distribution>
|
||||
generate_2(Random const& rnd, RealType v) const {
|
||||
return throw std::runtime_error(SPROUT_RECURSIVE_FUNCTION_TEMPLATE_INSTANTIATION_EXCEEDED_MESSAGE),
|
||||
sprout::random::random_result<Engine, binomial_distribution>()
|
||||
;
|
||||
return sprout::throw_recursive_function_template_instantiation_exeeded();
|
||||
}
|
||||
template<int D, typename Engine, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_CONTINUE(D)>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, binomial_distribution>
|
||||
|
@ -455,9 +430,7 @@ namespace sprout {
|
|||
template<int D, typename Engine, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_BREAK(D)>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, binomial_distribution>
|
||||
generate_1_1(Engine const& eng, RealType u) const {
|
||||
return throw std::runtime_error(SPROUT_RECURSIVE_FUNCTION_TEMPLATE_INSTANTIATION_EXCEEDED_MESSAGE),
|
||||
sprout::random::random_result<Engine, binomial_distribution>()
|
||||
;
|
||||
return sprout::throw_recursive_function_template_instantiation_exeeded();
|
||||
}
|
||||
template<int D, typename Engine, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_CONTINUE(D)>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, binomial_distribution>
|
||||
|
@ -470,9 +443,7 @@ namespace sprout {
|
|||
template<int D, typename Engine, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_BREAK(D)>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, binomial_distribution>
|
||||
generate_1(Engine const& eng, RealType v) const {
|
||||
return throw std::runtime_error(SPROUT_RECURSIVE_FUNCTION_TEMPLATE_INSTANTIATION_EXCEEDED_MESSAGE),
|
||||
sprout::random::random_result<Engine, binomial_distribution>()
|
||||
;
|
||||
return sprout::throw_recursive_function_template_instantiation_exeeded();
|
||||
}
|
||||
template<int D, typename Engine, typename Random, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_CONTINUE(D)>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, binomial_distribution>
|
||||
|
@ -482,9 +453,7 @@ namespace sprout {
|
|||
template<int D, typename Engine, typename Random, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_BREAK(D)>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, binomial_distribution>
|
||||
generate_0(Random const& rnd) const {
|
||||
return throw std::runtime_error(SPROUT_RECURSIVE_FUNCTION_TEMPLATE_INSTANTIATION_EXCEEDED_MESSAGE),
|
||||
sprout::random::random_result<Engine, binomial_distribution>()
|
||||
;
|
||||
return sprout::throw_recursive_function_template_instantiation_exeeded();
|
||||
}
|
||||
template<int D = 16, typename Engine, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_CONTINUE(D)>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, binomial_distribution>
|
||||
|
@ -494,9 +463,7 @@ namespace sprout {
|
|||
template<int D = 16, typename Engine, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_BREAK(D)>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, binomial_distribution>
|
||||
generate(Engine const& eng) const {
|
||||
return throw std::runtime_error(SPROUT_RECURSIVE_FUNCTION_TEMPLATE_INSTANTIATION_EXCEEDED_MESSAGE),
|
||||
sprout::random::random_result<Engine, binomial_distribution>()
|
||||
;
|
||||
return sprout::throw_recursive_function_template_instantiation_exeeded();
|
||||
}
|
||||
#else
|
||||
template<typename Engine>
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#include <sprout/config.hpp>
|
||||
#include <sprout/random/random_result.hpp>
|
||||
#ifdef SPROUT_WORKAROUND_NOT_TERMINATE_RECURSIVE_CONSTEXPR_FUNCTION_TEMPLATE
|
||||
# include <stdexcept>
|
||||
# include <sprout/workaround/recursive_function_template.hpp>
|
||||
#endif
|
||||
|
||||
|
@ -65,9 +64,7 @@ namespace sprout {
|
|||
template<int D, typename Engine, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_BREAK(D)>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, uniform_01>
|
||||
generate_1(Engine const& eng, sprout::random::random_result<Engine> const& rnd, result_type result) const {
|
||||
return throw std::runtime_error(SPROUT_RECURSIVE_FUNCTION_TEMPLATE_INSTANTIATION_EXCEEDED_MESSAGE),
|
||||
sprout::random::random_result<Engine, uniform_01>()
|
||||
;
|
||||
return sprout::throw_recursive_function_template_instantiation_exeeded();
|
||||
}
|
||||
template<int D = 16, typename Engine, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_CONTINUE(D)>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, uniform_01>
|
||||
|
@ -88,9 +85,7 @@ namespace sprout {
|
|||
template<int D = 16, typename Engine, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_BREAK(D)>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, uniform_01>
|
||||
generate(Engine const& eng, sprout::random::random_result<Engine> const& rnd) const {
|
||||
return throw std::runtime_error(SPROUT_RECURSIVE_FUNCTION_TEMPLATE_INSTANTIATION_EXCEEDED_MESSAGE),
|
||||
sprout::random::random_result<Engine, uniform_01>()
|
||||
;
|
||||
return sprout::throw_recursive_function_template_instantiation_exeeded();
|
||||
}
|
||||
#else
|
||||
template<typename Engine>
|
||||
|
|
|
@ -9,5 +9,6 @@
|
|||
#include <sprout/utility/enabler_if.hpp>
|
||||
#include <sprout/utility/pack.hpp>
|
||||
#include <sprout/utility/value_holder.hpp>
|
||||
#include <sprout/utility/any_convertible.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_UTILITY_HPP
|
||||
|
|
19
sprout/utility/any_convertible.hpp
Normal file
19
sprout/utility/any_convertible.hpp
Normal file
|
@ -0,0 +1,19 @@
|
|||
#ifndef SPROUT_UTILITY_ANY_CONVERTIBLE_HPP
|
||||
#define SPROUT_UTILITY_ANY_CONVERTIBLE_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
// any_convertible
|
||||
//
|
||||
struct any_convertible {
|
||||
public:
|
||||
template<typename T>
|
||||
SPROUT_CONSTEXPR operator T() const {
|
||||
return T();
|
||||
}
|
||||
};
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_UTILITY_ANY_CONVERTIBLE_HPP
|
|
@ -1,7 +1,10 @@
|
|||
#ifndef SPROUT_WORKAROUND_RECURSIVE_FUNCTION_TEMPLATE_HPP
|
||||
#define SPROUT_WORKAROUND_RECURSIVE_FUNCTION_TEMPLATE_HPP
|
||||
|
||||
#include <stdexcept>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/utility/forward.hpp>
|
||||
#include <sprout/utility/any_convertible.hpp>
|
||||
#include <sprout/type_traits/enabler_if.hpp>
|
||||
#include <sprout/preprocessor/stringize.hpp>
|
||||
|
||||
|
@ -36,4 +39,32 @@
|
|||
#define SPROUT_RECURSIVE_FUNCTION_TEMPLATE_INSTANTIATION_EXCEEDED_MESSAGE \
|
||||
"recursive template instantiation exceeded maximum depth of " SPROUT_PP_STRINGIZE(SPROUT_RECURSIVE_FUNCTION_TEMPLATE_INSTANTIATION_LIMIT)
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
// recursive_function_template_instantiation_exeeded
|
||||
//
|
||||
class recursive_function_template_instantiation_exeeded
|
||||
: public std::runtime_error
|
||||
{
|
||||
public:
|
||||
recursive_function_template_instantiation_exeeded() SPROUT_NOEXCEPT
|
||||
: std::runtime_error(SPROUT_RECURSIVE_FUNCTION_TEMPLATE_INSTANTIATION_EXCEEDED_MESSAGE)
|
||||
{}
|
||||
};
|
||||
|
||||
//
|
||||
// throw_recursive_function_template_instantiation_exeeded
|
||||
//
|
||||
template<typename T = sprout::any_convertible>
|
||||
inline SPROUT_CONSTEXPR T
|
||||
throw_recursive_function_template_instantiation_exeeded() {
|
||||
return throw sprout::recursive_function_template_instantiation_exeeded(), T();
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR T&&
|
||||
throw_recursive_function_template_instantiation_exeeded(T&& t) {
|
||||
return throw sprout::recursive_function_template_instantiation_exeeded(), sprout::forward<T>(t);
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_WORKAROUND_RECURSIVE_FUNCTION_TEMPLATE_HPP
|
||||
|
|
Loading…
Reference in a new issue