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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:19:52+00:00 2026-05-25T15:19:52+00:00

This compiles fine in GCC 3 and 4. MSVC++ can’t figure out the type

  • 0

This compiles fine in GCC 3 and 4. MSVC++ can’t figure out the type of noFunction and throws some hideous errors. Note if you cast noFunction to BFunction, it works just fine in VS2010.

My question: is this a defect in VS2010, or GCC bending the rules?

#include <map>

using namespace std;

typedef bool (*AFunction)(int arg1, int arg2);
typedef bool (*BFunction)(long arg1, bool arg2);

bool noFunction(long, bool) { return true; }

void test(AFunction a)
{

    make_pair(a, noFunction); //fails in VS2010

}

N.B. casting noFunction to BFunction fixes the problem in VS2010.

make_pair(a, (BFunction)noFunction);  //works everywhere

.

.

.

Here is the error for reference:

    1>  makepairtest.cpp
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\type_traits(197): error C2752: 'std::tr1::_Remove_reference<_Ty>' : more than one partial specialization matches the template argument list
1>          with
1>          [
1>              _Ty=bool (__cdecl &)(long,bool)
1>          ]
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\xtr1common(356): could be 'std::tr1::_Remove_reference<_Ty&&>'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\xtr1common(350): or       'std::tr1::_Remove_reference<_Ty&>'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\type_traits(962) : see reference to class template instantiation 'std::tr1::remove_reference<_Ty>' being compiled
1>          with
1>          [
1>              _Ty=bool (__cdecl &)(long,bool)
1>          ]
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\utility(26) : see reference to class template instantiation 'std::tr1::decay<_Ty>' being compiled
1>          with
1>          [
1>              _Ty=bool (__cdecl &)(long,bool)
1>          ]
1>          c:\xxx\makepairtest.cpp(14) : see reference to class template instantiation 'std::tr1::_Unrefwrap<_Type>' being compiled
1>          with
1>          [
1>              _Type=bool (__cdecl &)(long,bool)
1>          ]
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\type_traits(965): error C2528: 'abstract declarator' : pointer to reference is illegal
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\type_traits(349): error C2528: 'type' : pointer to reference is illegal
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\type_traits(967) : see reference to class template instantiation 'std::tr1::add_pointer<_Ty>' being compiled
1>          with
1>          [
1>              _Ty=bool (__cdecl &)(long,bool)
1>          ]
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\utility(148): error C2535: 'std::_Pair_base<_Ty1,_Ty2>::_Pair_base(const _Ty1 &,const _Ty2)' : member function already defined or declared
1>          with
1>          [
1>              _Ty1=bool (__cdecl *)(int,int),
1>              _Ty2=bool (__cdecl &)(long,bool)
1>          ]
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\utility(134) : see declaration of 'std::_Pair_base<_Ty1,_Ty2>::_Pair_base'
1>          with
1>          [
1>              _Ty1=bool (__cdecl *)(int,int),
1>              _Ty2=bool (__cdecl &)(long,bool)
1>          ]
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\utility(174) : see reference to class template instantiation 'std::_Pair_base<_Ty1,_Ty2>' being compiled
1>          with
1>          [
1>              _Ty1=bool (__cdecl *)(int,int),
1>              _Ty2=bool (__cdecl &)(long,bool)
1>          ]
1>          c:\xxx\makepairtest.cpp(14) : see reference to class template instantiation 'std::pair<_Ty1,_Ty2>' being compiled
1>          with
1>          [
1>              _Ty1=bool (__cdecl *)(int,int),
1>              _Ty2=bool (__cdecl &)(long,bool)
1>          ]
  • 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-25T15:19:53+00:00Added an answer on May 25, 2026 at 3:19 pm

    Taking the address of noFunction works with VC10 and gcc 4.5.2, i.e.:

    make_pair(a, &noFunction);
    

    Per the error message you posted, I would guess it has to do with how VC handles binding to rvalues.

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

Sidebar

Related Questions

This compiles fine in MSVC but gcc complains. The code on ideone . I
The following compiles fine: Object o = new Object(); System.out.println(o instanceof Cloneable); But this
Please check this code out it compiles and runs absolutely fine.. The question is
This code compiles just fine on gcc, but when using llvm (llvm-gcc), it says
Ok, this compiles fine in GCC under Linux. char * _v3_get_msg_string(void *offset, uint16_t *len)
This compiles fine in Visual studio, but why not in XCode? class A() {};
This code compiles fine: {-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, FlexibleInstances, UndecidableInstances, FlexibleContexts, EmptyDataDecls, ScopedTypeVariables, TypeOperators,
I'm having a hard time using std::string::iterators in C++. This code compiles fine (still
This confuses me. The following compiles fine under Eclipse. package com.example.gotchas; public class GenericHelper1
This typedef: typedef DWORD WINAPI (* CM_Open_DevNode_Key)(DWORD, DWORD, DWORD, DWORD, PHKEY, DWORD); compiles fine

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.