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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:18:07+00:00 2026-06-16T00:18:07+00:00

this class is much larger, but i’ll just post the offending code. template<class T>

  • 0

this class is much larger, but i’ll just post the offending code.

template<class T>
class BaseWindow : public IWindow
{
   typedef void(T::*HandlerPtr)(WPARAM, LPARAM)

public:
   LRESULT CALLBACK BaseWindow<T>::WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);

   // various stuff

private:
   void AddHandler(long id, HandlerPtr func);

private:
   std::map<long, void(T::*)(WPARAM, LPARAM)> m_MessageHandlers;
}

template<class T>
void BaseWindow<T>::AddHandler(long id, HandlerPtr func)
{
    m_MessageHandler.insert(std::pair<long, HandlerPtr>(id, func));
}

template<class T>
LRESULT CALLBACK Dapper32::BaseWindow<T>::WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
    if(m_MessageHandlers.count(msg) == 1)
    {
        auto it = m_MessageHandlers.find(msg);
        it->second(wparam, lparam);   // <-- error here for all template instantiations
        return 0;
    }

    return DefWindowProc(hwnd, msg, wparam, lparam);
}

Here’s a little background. For fun and practice, i’m making a win32 wrapper since it seems like a fun, lengthy project to tackle. After a bit of a deliberation, i decided that i preferred a system of storing message handlers in maps rather than each message getting there own virtual function, or worse even, working with a giant switch statement. What the goal here is, you derive from this BaseWindow class and then the template parameter is that derived class. Something like

class MyWindow : public BaseWindow<MyWindow>

then you make private methods that will handle a specific message, and then call the AddHandler function passing in the message id, and then a pointer to that method. Easy as cake, and i’ve verified that they are entered into the map correctly. However, in the BaseWindow class, i get the error:

error C2064: term does not evaluate to a function taking 2 arguments

I find this odd because every place i pass around the pointer, the declaration certainly does take two arguments. When i remove the parentheses and arguements to make it look like:

it->second;

it compiles and runs, and of course, none of the handlers are called, but how can it even compile when a function pointer with two parameters is invoked without taking an arguement list? something is fishy and frankly i don’t get it. Do any of you brilliant minds have any insight into 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-16T00:18:08+00:00Added an answer on June 16, 2026 at 12:18 am

    Can’t remove the question so i guess i’ll exlain how i solved it. got rid of the method pointers altogether, used std::functions in the map, and then used std::bind in the add handler function calls. much easier to work with system and method pointers are harder to store in a map together.

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

Sidebar

Related Questions

This is my situation, very much simplified. My classes; public class ClassBase { [Key]
Given this class public partial class Default : Page { private IRepository repo; ...
given this class definition: public class Frame { IFrameStream CapturedFrom; } I want implement
Take this class as example: public class Category : PersistentObject<int> { public virtual string
I've got a xml in the following form (but much larger..) <entry> <lemma>coaster</lemma> <sense>
I have a simple class that holds skeleton for a much larger, bulkier class.
I have this simplified code: <div class=container> <input type=submit name=submit class=submit value=Sign Up> </div>
This class hangs at Future.get() method after executing ExecutorService.shutdownNow() called. I don't know what
This class extends Thread and once it is created, the thread is started. This
Consider this class hierarchy: Book extends Goods Book implements Taxable As we know, there

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.