1
0
Fork 0
mirror of https://github.com/bolero-MURAKAMI/Sprout synced 2024-12-03 21:15:42 +00:00
Sprout/sprout/detail/param_at.hpp

65 lines
1.5 KiB
C++
Raw Normal View History

2011-09-01 02:48:32 +00:00
#ifndef SPROUT_DETAIL_PARAM_AT_HPP
#define SPROUT_DETAIL_PARAM_AT_HPP
#include <cstddef>
#include <type_traits>
#include <sprout/config.hpp>
namespace sprout {
2012-04-14 15:48:31 +00:00
namespace detail {
template<typename R, typename T, typename... Values>
inline SPROUT_CONSTEXPR typename std::enable_if<
sizeof...(Values) == 0,
R
>::type param_at(
std::size_t n,
T const& v,
Values const&... values
)
{
return v;
}
template<typename R, typename T, typename... Values>
inline SPROUT_CONSTEXPR typename std::enable_if<
sizeof...(Values) != 0,
R
>::type param_at(
std::size_t n,
T const& v,
Values const&... values
)
{
return n == 0 ? v : sprout::detail::param_at<R>(n - 1, values...);
}
template<typename R, typename T, typename... Values>
inline SPROUT_CONSTEXPR typename std::enable_if<
sizeof...(Values) == 0,
R
>::type param_seq_at(
std::size_t n,
std::size_t m,
T const& v,
Values const&... values
)
{
return v[m];
}
template<typename R, typename T, typename... Values>
inline SPROUT_CONSTEXPR typename std::enable_if<
sizeof...(Values) != 0,
R
>::type param_seq_at(
std::size_t n,
std::size_t m,
T const& v,
Values const&... values
)
{
return n == 0 ? v[m] : sprout::detail::param_seq_at<R>(n - 1, m, values...);
}
2012-04-14 15:48:31 +00:00
} // namespace detail
2011-09-01 02:48:32 +00:00
} // namespace sprout
#endif // #ifndef SPROUT_DETAIL_PARAM_AT_HPP