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

  • Home
  • SEARCH
  • 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 7937449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T22:31:43+00:00 2026-06-03T22:31:43+00:00

Today I encountered a terrible problem. I’ve been working on a whole framework with

  • 0

Today I encountered a terrible problem.
I’ve been working on a whole framework with a class using variadic templates. And it turns out the guy I’m working with uses visual studio, which doesn’t support variadic templates yet.

I tried to port the feature seamlessly by using macro, but after long work, it looks like it isn’t possible as is.
The problem is the quantity of parameter for the template may vary from zero to four (or to infinity with variadic templates).

Even though my macro are made, and expended in something like this :

template<>
Signal<void ()>
{
// My class
};

or

template<typename param1>
Signal<void (param1)>
{
// My class
};

But the problem is it looks like this doesn’t work with gcc (so I’ll assume it won’t with vc as well).

The header doesn’t show any errors, but if I try to instantiate the class like this :

Signal<> mySignal;

I get these kind of errors :

error: wrong number of template arguments (0, should be 1)

Since I find no information on the subject, I’d at least like to know if what I’m trying is possible ?
Or if I’m really going to have to write again hundreds of lines of code because Microsoft doesn’t think variadic templates are important enough ??

  • 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-03T22:31:43+00:00Added an answer on June 3, 2026 at 10:31 pm

    You cannot have a template with no arguments, the common approach to your problem is to use void or any other placeholder. Note that since you are simulating a function-like object, you can probably simplify this by using a single type that is a function signature:

    Signal< void() >
    

    That way there is always a single template argument, and you just need to provide specializations of that template for the cases where the signature has 0 to 4 arguments:

    template <typename S>
    struct Signal;
    
    template <typename arg1>
    struct Signal<void (arg1)> { ... };
    template <typename arg1, typename arg2>
    struct Signal<void (arg1,arg2)> { ... };
    

    If you are building a signal/handler or events library, I recommend that you take a look at existing implementations. Consider using or at least looking at the code in boost signals/signals2 library, for example.


    The header doesn’t show any errors, but if I try to instantiate the class like this :

    Signal<> mySignal;
    

    The problem is that your template takes a single argument, that is a function signature, but you are not providing any argument. At the point of instantiation you need to provide the template arguments. You probably mean to do:

    Signal<void ()> mySignal;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I encountered today a weird bug with an app I'm working on. The problem
Encountered a frustrating problem in our application today which came down to an ArrayIndexOutOfBounds
I have encountered this problem today and I don't have an explanation for it.
I encountered an interesting problem today which I thought was not possible in Java.
Hi Today I encountered a new problem with MouseWheel I have written some codes
I have been writing java for a while, and today I encountered the following
So I ran into a problem today while working on my Android program. I
I am actually using this calendar source code, but I did encountered a problem
Today, i encountered a problem. Xcode worked fine with my iphone4 device and provision
Today I noticed that the code I have been using to display a FBDialog

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.