2) `requires` can only have expression, declaration is not allowed.
(i.e. T t; is not allowed, but T{} ok)
(i.e. T t; is not allowed, but T{} ok)
template<typename S, typename T>
concept can_narrow = requires() {
T {std::declval<S>()};
};
int main() {
if constexpr (can_narrow<float, int>) {
cout << "double to int ok";
} else{
cout << "double to int not ok"; // hit here.
}
}
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.