I wrote the Signal / Slot library ( Codeproject article here ) under Linux, compiling both Clang 3.5 and GCC4.9. It compiles without warning on both compilers (also in versions 3.4 and 4.8). When I got everything that worked and published an article on the Internet, it did not take much time until I had complaints that it did not work on MSVC. (Visual Studio Express 2013? Sorry, I'm not familiar with the version control system.) I installed it in a virtual machine to look at myself and found that it did not compile the following:
template <typename Signature> struct RemoveCV; template <typename R, typename ... Args> struct RemoveCV<T, R (Args...)> { using Type = R(Args...); }; template <typename R, typename ... Args> struct RemoveCV<T, R(Args...) const> { using Type = R(Args...); };
The reason is that R(Args ...) not a member function, so it cannot have a const qualifier.
Although it is true that it makes no sense to have a const qualifier for a function that is not a member, I believe that I read somewhere (here on SO, including a quote from the standard) that this is until it is associated with the actual function. That is, it is allowed as an autonomous type. Unfortunately, I seem to be unable to find this thread anymore ...
I'm just wondering who exactly about this: MSVC or GCC + Clang, and what the standard has to say about the autonomous function signature, for example void() const .
c ++ c ++ 11
Jorenheit
source share