Here is what I am roughly trying to achieve:
// the declaration template<typename... Args> struct ArgsEstimate; // specialisation for string, SFINAE would be overkill template<typename... Args> struct ArgsEstimate<std::string&, Args...> { static const std::size_t size = 64 + ArgsEstimate<Args...>::size; }; // specialisation for arithmetic types template<typename AirthmeticT, typename std::enable_if<std::is_arithmetic<AirthmeticT>::value>::type* = nullptr, typename... Args> struct ArgsEstimate<AirthmeticT, Args...> { static const std::size_t size = sizeof(AirthmeticT) + ArgsEstimate<Args...>::size; }; // specialisation for pointer types template<typename PtrT, typename std::enable_if<std::is_pointer<PtrT>::value>::type* = nullptr, typename... Args> struct ArgsEstimate<PtrT, Args...> { static const std::size_t size = 32 + ArgsEstimate<Args...>::size; };
The problem is that this code gives a compilation error "template parameters not deducible in partial specialization" at the points I have done enable_if
. A static_assert
inside the struct won't work either since there will be redefinition.
I know, I can probably do this with SFINAE and function overloading alone. However, for cases like just std::string
, using SFINAE is an overkill.
So I was wondering if there is clean way of mixing template specialisation and SFINAE.