Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8605667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:53:48+00:00 2026-06-12T02:53:48+00:00

Possible Duplicate: using declaration in variadic template I recently came across a generic mechanism

  • 0

Possible Duplicate:
using declaration in variadic template

I recently came across a generic mechanism for combining two function objects to form a new function object that 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 for N function objects, using variadic templates:

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

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

However, GCC complains about my attempt to do variadic expansion on the using-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’ve tried some variations, such as:

using Fs::operator()...;

and

using Fs...::operator();

but neither do the trick.

Is it possible to do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T02:53:50+00:00Added an answer on June 12, 2026 at 2:53 am

    Instead of “I recently came across a generic mechanism”, please provide references such as “I recently came across a blog posting by Dave Abrahams describing a generic mechanism”….

    I doubt that parameter pack expansion is supported for using statement, and I’m sorry I don’t have the time to check the standard – that’s again your job, to read the documentation before asking the question.

    But as a practical matter of solving the problem at hand (rather than the language question), you can always code this up recursively instead of using direct expansion. Just inherit from a class that brings in the rest of the functors, then bring in the first one. Where “the rest” is the recursive step, terminating at an empty list of functors as base case.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Why should the implementation and the declaration of a template class be
Possible Duplicate: VB Using colons to put two statements on same line I have
Possible Duplicate: Sort list using stl sort function My question is can we sort
Possible Duplicate: Do I need to release NSString generated using @“…”? There are two
Possible Duplicate: ArrayList declaration Java In Java, why is an ArrayList often declared using
Possible Duplicate: using jquery $.ajax to call a PHP function I need to call
Possible Duplicate: Getting Using two-stage rotation animation warning with UIImagePickerController In my iphone app
Possible Duplicate: Using A* to solve Travelling Salesman Problem I have recently learned that
Possible Duplicate: Using jQuery to compare two arrays I need a Javascript or jQuery
Possible Duplicate: Using Git with an existing Xcode project Setting up a git repository

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.