1

Say I have a class that has some templated arguments, and a function that can access each one of those arguments such as

template <typename... Types>
class Foo
{
public:
    template <typename Type>
    Type& get() { return std::get<Type>(member_tuple); }

protected:
    std::tuple<Types...> member_tuple;
};

And I want to use this class as a base class and specialize the get() function in the child class to do something ... special ... but not so specialized as to define any of the template arguments just yet. Perhaps something like this:

template <typename... Types>
class Bar
    : public Foo<Types...>
{
public:
    template <typename Type>
    Type& special_get() 
    {
        // do your special thing in here somewhere.
        return Foo<Types...>::get<Type>(this->member_tuple); 
    }
};

However, that's a compiler error: it complains that it expected return Foo<Types...>::get(this->member_tuple).

To confuse me further, if I leave out the <Type> argument, and then try to call that function, I get a "couldn't deduce template parameter 'Type'" error instead.

How do I go about passing the additional template argument to the wrapped base class function?

MrBZapp
  • 109
  • 7

0 Answers0