2013-08-08 09:54:33 +00:00
|
|
|
/*=============================================================================
|
2019-01-07 08:47:17 +00:00
|
|
|
Copyright (c) 2011-2019 Bolero MURAKAMI
|
2013-08-08 09:54:33 +00:00
|
|
|
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)
|
|
|
|
=============================================================================*/
|
2012-11-12 04:29:56 +00:00
|
|
|
#ifndef SPROUT_WORKAROUND_RECURSIVE_FUNCTION_TEMPLATE_HPP
|
|
|
|
#define SPROUT_WORKAROUND_RECURSIVE_FUNCTION_TEMPLATE_HPP
|
|
|
|
|
2012-11-13 13:17:10 +00:00
|
|
|
#include <stdexcept>
|
2012-11-12 04:29:56 +00:00
|
|
|
#include <sprout/config.hpp>
|
2012-11-13 13:17:10 +00:00
|
|
|
#include <sprout/utility/forward.hpp>
|
|
|
|
#include <sprout/utility/any_convertible.hpp>
|
2012-11-12 04:29:56 +00:00
|
|
|
#include <sprout/type_traits/enabler_if.hpp>
|
|
|
|
#include <sprout/preprocessor/stringize.hpp>
|
2014-01-27 10:09:00 +00:00
|
|
|
#include <sprout/detail/predef.hpp>
|
2012-11-12 04:29:56 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// SPROUT_RECURSIVE_FUNCTION_TEMPLATE_INSTANTIATION_LIMIT
|
|
|
|
//
|
|
|
|
#ifndef SPROUT_RECURSIVE_FUNCTION_TEMPLATE_INSTANTIATION_LIMIT
|
2014-01-27 10:09:00 +00:00
|
|
|
# if SPROUT_CLANG_OR_LATER(3, 3, 0)
|
|
|
|
# define SPROUT_RECURSIVE_FUNCTION_TEMPLATE_INSTANTIATION_LIMIT 256
|
2013-06-17 14:44:18 +00:00
|
|
|
# else
|
|
|
|
# define SPROUT_RECURSIVE_FUNCTION_TEMPLATE_INSTANTIATION_LIMIT 512
|
|
|
|
# endif
|
2012-11-12 04:29:56 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
//
|
|
|
|
// SPROUT_RECURSIVE_FUNCTION_TEMPLATE_CONTINUE_DECL
|
|
|
|
// SPROUT_RECURSIVE_FUNCTION_TEMPLATE_BREAK_DECL
|
|
|
|
//
|
2014-08-14 13:55:49 +00:00
|
|
|
#define SPROUT_RECURSIVE_FUNCTION_TEMPLATE_CONTINUE_DECL(DEPTH) \
|
|
|
|
typename sprout::enabler_if<((DEPTH) < SPROUT_RECURSIVE_FUNCTION_TEMPLATE_INSTANTIATION_LIMIT - 1)>::type
|
|
|
|
#define SPROUT_RECURSIVE_FUNCTION_TEMPLATE_BREAK_DECL(DEPTH) \
|
|
|
|
typename sprout::enabler_if<((DEPTH) >= SPROUT_RECURSIVE_FUNCTION_TEMPLATE_INSTANTIATION_LIMIT - 1)>::type
|
2012-11-12 04:29:56 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// SPROUT_RECURSIVE_FUNCTION_TEMPLATE_CONTINUE
|
|
|
|
// SPROUT_RECURSIVE_FUNCTION_TEMPLATE_BREAK
|
|
|
|
//
|
2014-08-14 13:55:49 +00:00
|
|
|
#define SPROUT_RECURSIVE_FUNCTION_TEMPLATE_CONTINUE(DEPTH) \
|
|
|
|
SPROUT_RECURSIVE_FUNCTION_TEMPLATE_CONTINUE_DECL(DEPTH) = sprout::enabler
|
|
|
|
#define SPROUT_RECURSIVE_FUNCTION_TEMPLATE_BREAK(DEPTH) \
|
|
|
|
SPROUT_RECURSIVE_FUNCTION_TEMPLATE_BREAK_DECL(DEPTH) = sprout::enabler
|
2012-11-12 04:29:56 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// SPROUT_RECURSIVE_FUNCTION_TEMPLATE_INSTANTIATION_EXCEEDED_MESSAGE
|
|
|
|
//
|
|
|
|
#define SPROUT_RECURSIVE_FUNCTION_TEMPLATE_INSTANTIATION_EXCEEDED_MESSAGE \
|
|
|
|
"recursive template instantiation exceeded maximum depth of " SPROUT_PP_STRINGIZE(SPROUT_RECURSIVE_FUNCTION_TEMPLATE_INSTANTIATION_LIMIT)
|
|
|
|
|
2012-11-13 13:17:10 +00:00
|
|
|
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) {
|
2014-02-22 07:32:51 +00:00
|
|
|
return throw sprout::recursive_function_template_instantiation_exeeded(), SPROUT_FORWARD(T, t);
|
2012-11-13 13:17:10 +00:00
|
|
|
}
|
|
|
|
} // namespace sprout
|
|
|
|
|
2012-11-12 04:29:56 +00:00
|
|
|
#endif // #ifndef SPROUT_WORKAROUND_RECURSIVE_FUNCTION_TEMPLATE_HPP
|