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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:10:06+00:00 2026-05-28T06:10:06+00:00

There the following data types: struct Item { double a, b; Item (double a_,

  • 0

There the following data types:

struct Item { double a, b; Item (double a_, double b_): a(a_), b(b_){}};
typedef std::pair <double, Item> TPair;
typedef std::vector <TPair> TData;

I want to copy 2 vectors into the vector of pairs:

int main(int argc, char* argv[])
{
    std::vector <double> t1;
    std::vector <Item> t2;

    TData data;

    //Error
    std::transform (t1.begin(), t1.end(), data.begin(), 
            std::bind2nd( std::ptr_fun( std::make_pair <double,Item > ), double() ) );
}

But the compiler stops with the following error:

Error   1   error C2784: 'std::pointer_to_binary_function<_Arg1,_Arg2,_Result,_Result(__fastcall *)(_Arg1,_Arg2)> 
std::ptr_fun(_Result (__fastcall *)(_Arg1,_Arg2))' : could not deduce template argument for 'overloaded function type' from 'overloaded function type'
Error   2   error C2784: 'std::pointer_to_binary_function<_Arg1,_Arg2,_Result,_Result(__fastcall *)(_Arg1,_Arg2)> 
std::ptr_fun(_Result (__fastcall *)(_Arg1,_Arg2))' : could not deduce template argument for 'overloaded function type' from 'overloaded function type'

Where is the problem? Thanks for your help. Compiler MSVS 2010 x86. I prefer a solution without Boost.

Updated question
An error has been found by dasblinkenlight, the corrected code:

std::transform (t1.begin(), t1.end(), data.begin(), std::bind1st( std::ptr_fun( std::make_pair <double,Item > ), double() ) );

But compiler shows the same error…

  • 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-28T06:10:07+00:00Added an answer on May 28, 2026 at 6:10 am

    The second argument of make_pair<double,Item> is Item, not double:

    std::transform (t1.begin(), t1.end(), data.begin(),
         std::bind2nd( std::ptr_fun( std::make_pair <double,Item > ), Item(0,0) ) );
    

    EDIT: For MS VS, I defined make_pair as follows:

    std::pair<double,Item> make_pair(const double db, const Item it) {
        return std::pair<double,Item>(db, it);
    }
    

    Then the invocation looks like this:

    std::transform (t1.begin(), t1.end(), data.begin(),
         std::bind2nd( std::ptr_fun<double,Item,std::pair<double,Item> >( make_pair), Item(0,0) ) );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There is a simple POD data type like struct Item { int value1; double
I am working on some legacy code. I have the following data types: typedef
Lets say, I have the following text file: Listing 1: Endianess=little AddressModel=32 typedef struct{
I have an output evbuffer that I want to populate with the following data:
I want to create data types for accessing and modifying a simple music library,
I understand the following elements : there is some sort of crawling (configured in
I have the following situation: There is a tool that gets an XSLT from
I have the following situation: There is one custom view inside of the first
i'm trying to do the following hope there's a reg_ex expert around to shed
I am trying to find an optimal solution for the following problem: there is

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.