I was trying an example about 1z's deduction guide by using gcc 8.0.0 201706 (Unable to get the code compiled by using clang 5.0.5).
namespace std
{
template<class R, class CLS, class ... ARGS> std::function(R(CLS::*)(ARGS ...)) -> function< R(CLS &, ARGS...)>;
}
The compiler complains that
error: explicit qualification in declaration of 'std::function(R (CLS::*)(ARGS ...))-> std::function<R(CLS&, ARGS ...)>'
-> function< R(CLS &, ARGS...)>;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
Based on explicit qualification in C++ declaration the qualification 'std::' should be removed to make the declaration right.
But when I change the deduction guide declaration to (NOTICE the qualification 'std::' is added after '->'). There is no compiler errors:
template<class R, class CLS, class ... ARGS> function(R(CLS::*)(ARGS ...))-> std::function< R(CLS &, ARGS...)>;
I assume the whole express is a declaration, but it seems the part after '->' is not.
It seems to me that a qualification is able to be used on one part of expression but not the other parts is a bit confusing. Is anyone able to explain the reason behind why the last expression is valid?
Thanks