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 3282840
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:58:23+00:00 2026-05-17T19:58:23+00:00

I currently have a class that uses template arguments. I need an array of

  • 0

I currently have a class that uses template arguments. I need an array of these. How could I do this (without boost).
ex:

template <typename RET, typename T>
class AguiTimedEvent {
    RET (*onEvent)(T arg);
    double timeStamp;
public:
    RET call(T arg);
    bool expired();
    AguiTimedEvent();
    AguiTimedEvent(RET (*Timefunc)(T arg), double timeSec);
};

and I would need to something like:

AguiTimedEvent t<int, int>(func, 5.0);
v.push_back(t);
...
v[0].call();

I don’t actually need the return value, but I just have it to make it more flexible. If the return value causes an issue I could limit it to void functions, but defiantly the arg needs to be templated. What can I do? Thanks

*I need the vector to handle any type, I need an array, where the array can dispatch events of X Y, not just int int

  • 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-05-17T19:58:23+00:00Added an answer on May 17, 2026 at 7:58 pm
    std::vector<AguiTimedEvent<int, int> > v;
    

    If you need to store objects of different AguiTimedEvent types that have different template arguments, you need to create a base class (e.g., AguiTimedEventBase) and store pointers in the vector.

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

Sidebar

Related Questions

I have a class that my client uses to Get() a packet. The packet
I am trying to write a container class which uses STL allocators. What I
I have a Visual Studio 2008 Windows Mobile 6 C++ application that is using
I have an ASP.NET MVC 2 application which in part allows a user to
Gday All, I have been dabbling in some F# of late and I came
I love to organize my code, so ideally I want one class per file
Note: Edited based on responses to receive more appropriate answers. I have a collection
Toward the end of Chapter 16 of the C++ Primer I encountered the following
I'm somewhat new to Python, Django, and I'd like some advice on how to
Before I write my own I will ask all y'all. I'm looking for a

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.