Questions tagged «if-constexpr»

1
如果constexpr-为什么要完全检查废弃的语句?
我在GCC 10中搞乱了c ++ 20 consteval并编写了这段代码 #include <optional> #include <tuple> #include <iostream> template <std::size_t N, typename Predicate, typename Tuple> consteval std::optional<std::size_t> find_if_impl(Predicate&& pred, Tuple&& t) noexcept { constexpr std::size_t I = std::tuple_size_v<std::decay_t<decltype(t)>> - N; if constexpr (N == 0u) { return std::nullopt; } else { return pred(std::get<I>(t)) ? std::make_optional(I) : find_if_impl<N …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.