How to distinguish multiple variadic templates

26 views Asked by At

I would like to define a method which can accept two different variadic types (A and B) trying to give a hint to the compiler to distinguish them, such as std::optional<B>:

#include <optional>

template <typename... A, typename... B>
void method(A... a, std::optional<B>&... b)
{
    // ...
};

Event when I instantiate A and B with a different type (for example bool and int respectively), GNU compiler is still unable to distinguish where A finishes and std::optional<B> starts:

method(true, false, std::optional<int>{0}); // note: candidate template ignored:
                                            // could not match 'std::optional<B>' against 'bool'

Is there any way to give a hint to the compiler to distinguish these two types?

0

There are 0 answers