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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:25:06+00:00 2026-05-18T04:25:06+00:00

I want to have a priority queue with custom ordering, but lazy as I

  • 0

I want to have a priority queue with custom ordering, but lazy as I am, I don’t want to define a comparator class implementing operator().

I really would like something like this to compile:

std::priority_queue<int, std::vector<int>, 
    boost::bind(some_function, _1, _2, obj1, obj2)> queue;

where some_function is a bool returning function taking four arguments, the first and second being ints of the queue, and the two last ones some objects needed for calculating the ordering (const references).

(error: ‘boost::bind’ cannot appear in a constant-expression)

But this doesn’t compile. Even a more simple

std::priority_queue<int, std::vector<int>, &compare> queue;

won’t compile, with compare being a binary function returning bool.

(error: type/value mismatch at argument 3 in template parameter list for ‘template class std::priority_queue’; expected a type, got ‘compare’)

Any suggestions?

  • 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-18T04:25:06+00:00Added an answer on May 18, 2026 at 4:25 am

    This could work:

    std::priority_queue<int, std::vector<int>, 
        boost::function<bool(int,int)> >
    

    Then pass in your bind expression to the queue’s constructor.

    P.S. you’re getting those compilation errors because you’re putting runtime-evaluated expressions where a typename or constant expression are expected.

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

Sidebar

Related Questions

I have a problem with stl priority queue.I want to have the priority queue
I have created a priority queue using the Java API and I want to
Possible Duplicate: Priority queue in .Net This question is similar, but i want to
I want to implement a priority queue class. When an item is added at
I have a priority queue implementation in C# that I want to add a
I have List I want to sort Desc by Priority, which is int and
I have a simple swipe gesture that I want to be very low priority.
How can I remove an arbitrary item from a priority queue. Suppose I have
I have a message queue where i add some emails. I want to extract
I'm implementing a game. I have a state tree and a set<> based priority

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.