Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/algorithm/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 在编译时计算范围的限制_C++_Algorithm_C++11_Templates - Fatal编程技术网

C++ 在编译时计算范围的限制

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)> {}

如果你只有一个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)> {};
实施过程包括:

// 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]();
}