[英]How can I require (in a C++20 concept) that a type T be a reference to a floating point type?
在 C++20 概念库中,有std::floating_point<T>
,“当且仅当 T 是浮点类型时才满足”( ref )。 但我需要T
成为对浮点类型的引用。 表达这一点的requires
子句是什么?
正如戴维斯在评论中所说,只需使用类型特征:
template <typename T>
concept is_floating_point_reference =
std::is_reference_v<T> &&
std::floating_point<std::remove_reference_t<T>>;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.