Say we have a class like this with a user-defined subtraction guide:
template<typename T, typename... Args> struct Foo { Foo(Args&&...) { std::cout << "just Args: " << __PRETTY_FUNCTION__ << std::endl; } Foo(Args&&..., T&&) { std::cout << "Args and T: " << __PRETTY_FUNCTION__ << std::endl; } }; template<typename... Args> Foo(Args&&...) -> Foo<Void, Args...>;
Now try to instantiate this class: Foo foo { 10 }; . What will be the template arguments output and which constructor will be called?
After some experimentation, this depends on the compiler. Namely, gcc 7 and clang 6 (from the trunk) seem to choose an automatic manual by creating T with int and Args with an empty package, so the output is
Args and T: Foo<T, Args>::Foo(Args&& ..., T&&) [with T = int; Args = {}]
clang 5, on the other hand, selects a user-defined guide:
just Args: Foo<Void, int>::Foo(Args &&...) [T = Void, Args = <int>]
Which choice is the right one, and how can I use a custom pin index in this case?
A complete example is available on wandbox .
source share