[英]Declaring a default templated function
假设我有以下内容:
// Foo.h
struct Foo {};
// Bar.h
struct Bar {
template <typename T, typename = typename std::enable_if<std::is_base_of<Foo, T>::value>::type>
void foobar();
};
// Bar.hpp
// ...?
void Bar::foobar() {}
如何在 Bar.hpp 上声明foobar
function?
默认参数必须指定一次。 所以这样做:
template <class T, class>
void Bar::foobar() {}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.