Код: Выделить всё
template
class Prop {
public:
Prop(const std::function &getter) : getter(getter) {}
Prop(const T &value) : getter([=]() { return value; }) {}
Prop(const char *value) : getter([=]() { return std::string(value); }) {}
T operator()() const {
return getter();
}
private:
const std::function getter;
};
Код: Выделить всё
void foo(const Prop &prop) {}
template
void bar(const Prop &prop) {}
int main() {
foo(0);
bar(0); // no instance of function template "bar" matches the argument listC/C++(304)
}
Источник: https://stackoverflow.com/questions/781 ... ter-in-c11
Мобильная версия