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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:10:48+00:00 2026-06-14T08:10:48+00:00

I get this compile error with the latest VC++ compiler (Nov 2012 CTP) when

  • 0

I get this compile error with the latest VC++ compiler (Nov 2012 CTP) when using static member function pointer as template argument:

error C2027: use of undefined type 'wrapper<int (int,int),int A::f1(int,int)>'

But when using free function, everything works ok.
I looked up some similar bugs in g++( pointer to static member function is "invalid" as a template argument for g++ ), but there it explicitly states that argument is invalid. What is so different about static functions?

I’m casting the function to void(*)(void) because construct like <typename T_Ret, typename... T_Args, T_Ret(*)(T_Args...)> don’t compile for some other urelated reasons.

struct A
{
    static int f1(int a, int b)
    {
        return a + b;
    }
};

int f2(int a, int b)
{
    return a + b;
}

template <typename Sig, void(*fnc)(void)>
struct wrapper;

template <void(*fnc)(void), typename T_Ret, typename... T_Args>
struct wrapper<T_Ret (T_Args...), fnc>
{
    static bool apply()
    {
        // get some ints here
        int a = 1;
        int b = 2;
        typedef T_Ret (fnc_ptr*)(T_Args...);
        int res = ( (fnc_ptr)fnc )(a, b);
        // do smth with result
        res;
        return true;    // or false
    }
};

int main()
{
    bool res;
    res = wrapper<decltype(A::f1), (void(*)(void))A::f1>::apply();  // error
    res = wrapper<decltype(f2), (void(*)(void))f2>::apply();  // compiles ok
    return 0;
}

EDIT:
Ok, I narrowed the issue to decltype.
When I write the type explicitly, everything works:

res = wrapper<int(int, int), (void(*)(void))A::f1>::apply();  // compiles ok
  • 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-14T08:10:50+00:00Added an answer on June 14, 2026 at 8:10 am

    EDIT:
    Looks like it’s a compiler bug: http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Core-C-/STLCCSeries6#c634886322325940618

    Workaround:

    Change decltype(A::f1) to decltype(&A::f1) which changed its output from int(int, int) to int (__cdecl *)(int,int). And change

    template <void(*fnc)(void), typename T_Ret, typename... T_Args>
    struct wrapper<T_Ret (T_Args...), fnc>
    

    to

    template <void(*fnc)(void), typename T_Ret, typename... T_Args>
    struct wrapper<T_Ret (*)(T_Args...), fnc>
    

    Working code:

    struct A
    {
        static int f1(int a, int b)
        {
            return a + b;
        }
    };
    
    template <typename Sig, void(*fnc)(void)>
    struct wrapper;
    
    template <void(*fnc)(void), typename T_Ret, typename... T_Args>
    struct wrapper<T_Ret (*)(T_Args...), fnc>
    {
        static bool apply()
        {
            // get some ints here
            int a = 1;
            int b = 2;
            typedef T_Ret (*fnc_ptr)(T_Args...);
            int res = ( (fnc_ptr)fnc )(a, b);
            // do smth with result
            res;
            return true;    // or false
        }
    };
    
    int main()
    {
        bool res;
        res = wrapper<decltype(&A::f1), (void(*)(void))A::f1>::apply();
        return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I get this to compile? The error is when I start using
I'm trying to compile the latest GnuTLS on Centos 6.2. I get this error
I always get this error when trying to compile my file with Boost::GIL PNG
When I compile a project I get this error: C:\DATOSA~1\FAXENG~1>nmake /f Makefile.vc clean Microsoft
I get a compile error, which I'm slightly confused about. This is on VS2003.
When I try to compile this project I get the following error. I would
I am trying to get a file size of remote file compiler-latest.zip (googlecode.com) using
I get this error when trying to make the executable, the code compiles correctly
For example, I get this compiler warning, The event 'Company.SomeControl.SearchClick' is never used. But
This is a very simple question for compiler guys, but I always get confused

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.