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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:23:38+00:00 2026-05-13T14:23:38+00:00

It works just fine, for plain vanilla functions. The code below works just fine.

  • 0

It works just fine, for plain vanilla functions. The code below works just fine. It prints just what is should:

int __cdecl(int, char)
2
int,char

#include <boost/type_traits.hpp>
#include <boost/function.hpp>
#include <boost/typeof/std/utility.hpp>

#include <iostream>

using std::cout;
using std::endl;

int foo(int, char) {
 return 0;
}
int main() {
    typedef BOOST_TYPEOF(foo) foo_type;;
    typedef boost::function_traits<foo_type> function_traits;

    cout << typeid(foo_type).name() << endl;
    cout << function_traits::arity << endl;
    cout << typeid(function_traits::arg1_type).name() << ",";
    cout << typeid(function_traits::arg2_type).name() << endl;

    return 0;
}

So, the question is, how can one do this if foo is a member function of class bar?

struct bar {
    int foo(int, char) { return 0; }
};

I have tried countless combinations of these constructs: BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP() BOOST_TYPEOF_REGISTER_TYPE() boost::ref boost::remove_pointer boost::bind boost::mem_fn

etc., etc… No joy.

  • 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-13T14:23:38+00:00Added an answer on May 13, 2026 at 2:23 pm

    Boost Function Types would probably be the natural solution:

    #include <boost/function_types/function_type.hpp>
    #include <boost/function_types/parameter_types.hpp>
    #include <boost/function_types/function_arity.hpp>
    #include <boost/typeof/std/utility.hpp>
    #include <boost/typeof/typeof.hpp>
    #include <iostream>
    
    struct bar {
        int foo(int, char) { return 0; }
    };
    
    int main() {
    
        typedef BOOST_TYPEOF(&bar::foo) foo_type;
    
        std::cout << typeid(foo_type).name() << std::endl;
        std::cout << boost::function_types::function_arity<foo_type>::value << std::endl;
        std::cout << typeid(boost::mpl::at_c<boost::function_types::parameter_types<foo_type>,1>::type).name() << ",";
        std::cout << typeid(boost::mpl::at_c<boost::function_types::parameter_types<foo_type>,2>::type).name() << ",";
    
        return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code which works just fine when the method is POST,
I have made a new windows service which works fine using barebone code (just
This works just fine: protected void txtTest_Load(object sender, EventArgs e) { if (sender is
I’ve just created a WCF service/client and it all works fine when running on
I wrote a small program with Boost in c++. It works fine and so
I've tried msysGit and Git on Cygwin. Both work just fine in and of
Now I'm trying to work with System.Web.Routing. All is just fine, but I can't
I need a collection that works just like a Dictionary/Hashtable in a sense that
I have an application that imports data from a pickled file. It works just
I have an method which save files to the internet, it works but just

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.