The C++17 class template argument deduction works just fine, but I am not able to create a type alias on such a type, where the class template argument deduction works.
Are there any special tweaks to using needed, that it works?
Here I have a minimal working example:
#include <utility>
template <typename T>
class cls {
public:
cls(T&& arg) : val(std::forward<T>(arg)) {}
private:
T val;
};
template <typename T>
using alias = cls<T>;
int main() {
cls c(1);
//alias b(2); //not working, but why?
alias<int> a(2);
}
This code should compile with g++8 and --std=c++17, but if I uncomment the commented line, I get the following error:
test.cpp:16:11: error: missing template arguments before ‘b’
alias b(2);//not working