Argument is not consteval in a 'if consteval' branch? [duplicate]
I am designing a class similar to an std::array. I have a constructor that receives an iterator and a size. My idea is fail if the size is bigger than N. N being a size_t class template parameter. My idea is to fail if the count parameter is bigger than N. In a consteval context at least, at runtime I can reduce the counter. Code: constexpr vector_stack_base(const_iterator source, size_type count) { if consteval { static_assert(N <= count); } else { if (count > N) { count = N; } } This codes fails in MSVC 2026, in C++23 in the static_assert, saying: "error C2131: expression did not evaluate to
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.