C++ 在编译时计算范围的限制
如果你只有一个SFINAE类作为工具,它接受一个索引并产生C++ 在编译时计算范围的限制,c++,algorithm,c++11,templates,C++,Algorithm,C++11,Templates,如果你只有一个SFINAE类作为工具,它接受一个索引并产生std::true\u type,如果它在范围内,你怎么能找到极限呢? 这是确切的要求,不能使用任何其他要求 这是结构的签名示例L这里是测试用的。在实际结构中,将有typename T作为第二个参数,但它与问题无关 template <size_t I, size_t L = 6000> struct is_in_range : std::integral_constant<bool, (I < L)> {}
std::true\u type
,如果它在范围内,你怎么能找到极限呢?
这是确切的要求,不能使用任何其他要求
这是结构的签名示例<代码>L这里是测试用的。在实际结构中,将有typename T
作为第二个参数,但它与问题无关
template <size_t I, size_t L = 6000>
struct is_in_range : std::integral_constant<bool, (I < L)> {};
实施过程包括:
// checks if this is well-formed to deduce the type of an element
decltype(pod{{explicitly_convertible<int>()}});
我在这里没有看到任何SFINAE。你说的“找到极限”是什么意思?你控制
是否在范围内?添加static constexpr auto supper_LIMIT=L会更容易代码>听起来像是XY问题。为什么极限L是未知的或者不是可以推断的?顺便说一句,实际的问题让我想起了magic_get(又名boost.pfr)。
// checks if this is well-formed to deduce the type of an element
decltype(pod{{explicitly_convertible<int>()}});
template <typename T, size_t N>
struct non_acceptable
{
operator T[N]();
}