我想让这个代码工作
#include <cstddef>
template <bool B, auto T, auto F>
struct conditional { static constexpr auto value = T; };
template <auto T, auto F>
struct conditional<false, T, F> { static constexpr auto value = F; };
template <std::size_t N, auto... Dims>
struct static_extent;
template <std::size_t N>
struct static_extent<N> {
static constexpr std::size_t value = 0;
};
template <std::size_t N, auto Dim, auto... Dims>
struct static_extent<N, Dim, Dims...> {
static constexpr auto value =
conditional<
(N == 0),
Dim,
static_extent<N-1, Dims...>::value
>::value;
};
enum class dynamic_extent_tag {};
inline constexpr dynamic_extent_tag dyn{-1};
int main()
{
static_assert(static_extent<1, 33, dyn, 19>::value == dyn, "");
static_assert(static_extent<0, 33, dyn, 19>::value == 33, "");
}
我已经在Godbolt上对其进行了测试,它似乎可以与 clang 一起使用。不幸的是,我被绑定到 gcc,它给了我一个 ICE 和一个堆栈跟踪。我试图在他们的bugzilla上冲浪,但我有点迷路了。
是否值得为主干版本提交错误报告?它甚至想要吗?有人知道这是否已经是一个已知问题吗?我寻找关键字“冰”,但在那里找不到任何有用的东西。