在概念定义中检查成员函数模板的存在
假设我有一个概念概念
和一堆类似类型的类型,这些类型提供了一个成员函数模板,如下所示:
class Typical {
template<Concept T>
auto something() { return ...; }
};
如何编写概念hassomething
测试存在此类存在的概念会员模板功能?请注意,该功能模板没有参数,被设计为obj.something&lt; t&gt;()
。我必须测试该函数是否可以使用任何概念
来调用。
edit :我想到的所有方法至少需要提供t
的实例。我可以想象如何测试典型::如果
如果某物
在其中应该是类模板,而不是用于函数模板,则对某种进行了很好的形式。
Suppose I have a concept Concept
and a bunch of similar types that provide a member function template as follows:
class Typical {
template<Concept T>
auto something() { return ...; }
};
How do I write a concept HasSomething
that tests for the existence of such a member template function? Note that the function template has no arguments and is designed to be called as obj.something<T>()
. I have to test whether the function is callable with any Concept
.
Edit: all the approaches I can think of require to at least provide an instance of T
. I can imagine how to test whether Typical::template something
is well-formed if something
where supposed to be a class template, but not for a function template.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论