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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:09:52+00:00 2026-05-26T18:09:52+00:00

I am trying to sort a vector below using boost::phoenix library. The class Foo

  • 0

I am trying to sort a vector below using boost::phoenix library. The class Foo has a member function ‘int getvalue()’. The purpose is to sort the vector using the value returned by ‘getvalue()’. But something is missing. I get compiler error as ‘::second is not a class or namespace’

      std::vector<std::pair<int, Foo> > fooVec;

      boost::phoenix::sort ( boost::phoenix::bind( &std::pair<int, Foo>::second::getvalue(), boost::phoenix::arg_names::arg1) (*fooVec.begin() ), std::less<int>() );

Can anybody please explain this. What changes do I need to make this work?

Thanks.

PS: I know I could have used function object/lambda or soemthing similar but I wanted to try out boost::phoenix.

  • 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-26T18:09:53+00:00Added an answer on May 26, 2026 at 6:09 pm

    As commented, I don’t think that your way of creating a phoenix actor from your vector can be used to sort it, but I never used the algorithms from phoenix so I not sure about it.
    You can of course use sort and create a functor with phoenix to sort it.
    So I would suggest to use phoenix this way.

    boost::phoenix::sort(boost::phoenix::placeholders::arg1, boost::phoenix::placeholders::arg2)(fooVec, 
            boost::phoenix::bind( &Foo::getvalue, boost::phoenix::bind( &std::pair<int, Foo>::second, boost::phoenix::placeholders::arg1)) < boost::phoenix::bind( &Foo::getvalue, boost::phoenix::bind( &std::pair<int, Foo>::second, boost::phoenix::placeholders::arg2))
            );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to sort a vector of objects using a predicate function and I'm
Within a class, I am trying to sort a vector, by passing a method
I'm trying to sort a vector that contains an int and a string in
I have a std::vector<std::pair<int,std::pair<Bone,std::string> > > I'm trying to sort it with std sort,
I'm trying to sort a Vector in java but my Vector is not a
I am trying to sort a list using delegates but I am getting a
I'm trying to sort a list (part of a class) in descending order containing
I am trying to sort a vector of custom struct in C++ struct Book{
I'm new to pl/sql ! I'm trying to sort a table of records, using
Trying to sort an array by writing my own sort method using recursion (Pine's

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.