Given the code in C ++ 17:
template<class T> struct Ok { T value; }; template<> struct Ok<void> {}; // template deduction guides template<class T> Ok(T) -> Ok<T>; Template deduction guides allow having the type Ok<T> call Ok as a function (this is what the constructor actually looks like):
auto c = Ok(5); // T deduced as int // без template deduction guide я так писать не могу, // но должен писать: auto c = Ok<int>(5); // T can not be deduced :( The question is how to rewrite it in C ++ 14 or lower? So I just wrote:
auto c = Ok("hello"s); // T deduced as std::string But with an arbitrary type.