คำถามติดแท็ก if-constexpr

1
if constexpr - เพราะเหตุใดคำสั่งที่ถูกยกเลิกจะถูกตรวจสอบอย่างสมบูรณ์?
ฉันยุ่งกับ c ++ 20 consteval ใน GCC 10 และเขียนรหัสนี้ #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)) …
โดยการใช้ไซต์ของเรา หมายความว่าคุณได้อ่านและทำความเข้าใจนโยบายคุกกี้และนโยบายความเป็นส่วนตัวของเราแล้ว
Licensed under cc by-sa 3.0 with attribution required.