Variable ad-use extension

Possible duplicate:
using an ad in a variation template

I recently met a general mechanism for combining two function objects to form a new functional object, which behaves as if the first two were overloaded

template <typename F1, typename F2>
struct overload : public F1, public F2
{
    overload(F1 f1, F2 f2) : F1(f1), F2(f2) {}

    using F1::operator();
    using F2::operator();
};

I am trying to extend this idea to work on objects of function N using variable templates:

template <typename... Fs>
struct overload : public Fs...
{
    overload(Fs... fs) : Fs(fs)... {}

    using Fs::operator();...
};

However, GCC complains about my attempt to make a variational extension to the use-declaration:

test.cpp:6:24: error: parameter packs not expanded with '...':
     using Fs::operator();...
                        ^
test.cpp:6:24: note:         'Fs'
test.cpp:6:26: error: expected unqualified-id before '...' token
     using Fs::operator();...
                          ^

I tried some options, for example:

using Fs::operator()...;

and

using Fs...::operator();

but also a trick.

Can this be done?

+5
source share
1 answer

, " ", , " " & hellip;.

, using, , – , , .

, ( ), , . , , . "" - , .

0

All Articles