|
|
prog.cpp: In function 'int main()': prog.cpp:22:48: error: no matching function for call to 'Helper<int>::Wrap(int&)' auto c2 = Helper<int>::Wrap<std::shared_ptr>(x); ^ prog.cpp:7:29: note: candidate: template<template<class ...> class typedef Wrapper Wrapper, class ... Args> static Wrapper<T, Args ...> Helper<T>::Wrap(const T&) [with Wrapper = Wrapper; Args = {Args ...}; T = int] static Wrapper<T, Args...> Wrap(T const &t) ^ prog.cpp:7:29: note: template argument deduction/substitution failed: prog.cpp: In substitution of 'template<template<class ...> class typedef Wrapper Wrapper, class ... Args> static Wrapper<T, Args ...> Helper<T>::Wrap(const T&) [with typedef Wrapper Wrapper = std::shared_ptr; Args = {}]': prog.cpp:22:48: required from here prog.cpp:7:29: error: wrong number of template arguments (2, should be 1) In file included from /usr/include/c++/5/bits/shared_ptr.h:52:0, from /usr/include/c++/5/memory:82, from prog.cpp:1: /usr/include/c++/5/bits/shared_ptr_base.h:345:11: note: provided for 'template<class _Tp> class std::shared_ptr' class shared_ptr; ^ prog.cpp:23:53: error: no matching function for call to 'Helper<int>::Wrap(int&)' auto c3 = Helper<int>::Wrap<WrapperHelper, int>(*c1); ^ prog.cpp:7:29: note: candidate: template<template<class ...> class typedef Wrapper Wrapper, class ... Args> static Wrapper<T, Args ...> Helper<T>::Wrap(const T&) [with Wrapper = Wrapper; Args = {Args ...}; T = int] static Wrapper<T, Args...> Wrap(T const &t) ^ prog.cpp:7:29: note: template argument deduction/substitution failed: |
main.cpp:22:12: error: no matching function for call to 'Wrap' auto c2 = Helper<int>::Wrap<std::shared_ptr>(x); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ main.cpp:7:29: note: candidate template ignored: substitution failure [with Wrapper = std::shared_ptr]: too many template arguments for class template 'shared_ptr' static Wrapper<T, Args...> Wrap(T const &t) ~~~~~~~ ^ main.cpp:23:12: error: no matching function for call to 'Wrap' auto c3 = Helper<int>::Wrap<WrapperHelper, int>(*c1); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ main.cpp:7:29: note: candidate template ignored: invalid explicitly-specified argument for template parameter 'Wrapper' static Wrapper<T, Args...> Wrap(T const &t) ^ 2 errors generated. |
static auto Wrap(T const &t)
solves 1st problem.
|
|
MiiNiPaa wrote: |
---|
With WrapperHelper you are trying to instantiate WrapperHelper<int, int> which probably is not allowed. |
|
|
A pack expansion consists of a pattern and an ellipsis, the instantiation of which produces zero or more instantiations of the pattern in a list (described below). The form of the pattern depends on the context in which the expansion occurs. Pack expansions can occur in the following contexts: ... <elided>... - In a template parameter pack that is a pack expansion: if the template parameter pack is a parameter-declaration; the pattern is the parameter-declaration without the ellipsis; if the template parameter pack is a type-parameter with a template-parameter-list; the pattern is the corresponding type-parameter without the ellipsis. ... <elided>... |
For the purpose of determining whether a parameter pack satisfies a rule regarding entities other than parameter packs, the parameter pack is considered to be the entity that would result from an instantiation of the pattern in which it appears. |
too many template arguments for class template 'A' template < typename... TYPES > A< int, TYPES... > foo() ; error: wrong number of template arguments (2, should be 1) template < typename... TYPES > A< int, TYPES... > foo() ; |
|
|