在概念定义中检查成员函数模板的存在

发布于 2025-02-05 14:20:02 字数 459 浏览 1 评论 0原文

假设我有一个概念概念和一堆类似类型的类型,这些类型提供了一个成员函数模板,如下所示:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文