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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:53:13+00:00 2026-06-09T13:53:13+00:00

I try to compile this function: #include <algorithm> #include <cmath> #include <functional> #include <vector>

  • 0

I try to compile this function:

#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>

void foo(unsigned n)
{
  std::vector<unsigned> some_vector;
  /* fill vector ... */
  auto le_sqrt_n = std::bind(std::less_equal<unsigned>, 
                             std::placeholders::_1, 
                             unsigned(sqrt(n))
                             );
  auto it = std::find_if(some_vector.rbegin(), some_vector.rend(), le_sqrt_n);
  /* do something with the result ... */
}

with gcc 4.6.3:

g++ -std=c++0x test_bind_02.cc

and get this error:

test_bind_02.cc: In function ‘void foo(unsigned int)’:
test_bind_02.cc:10:55: error: expected primary-expression before ‘,’ token
test_bind_02.cc:13:9: error: unable to deduce ‘auto’ from ‘<expression error>’
test_bind_02.cc:14:77: error: unable to deduce ‘auto’ from ‘<expression error>’

What is my (presumably stupid) mistake?

  • 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-09T13:53:14+00:00Added an answer on June 9, 2026 at 1:53 pm

    You don’t call std::less_equal<unsigned> c-tor.
    This code works okay.

    http://liveworkspace.org/code/7f779d3fd6d521e8d4012a4066f2c40f

    std::bind has two forms.

    template< class F, class... Args >
    /*unspecified*/ bind( F&& f, Args&&... args );
    template< class R, class F, class... Args >
    /*unspecified*/ bind( F&& f, Args&&... args );
    

    since std::less_equal is struct you should pass to this function as F fully-constructed object. Works code is

    #include <algorithm>
    #include <cmath>
    #include <functional>
    #include <vector>
    
    void foo(unsigned n)
    {
      std::vector<unsigned> some_vector;
      /* fill vector */
      auto le_sqrt_n = std::bind(std::less_equal<unsigned>(),
                     std::placeholders::_1, 
                     unsigned(sqrt(n))
                     );
      auto it = std::find_if(some_vector.rbegin(), some_vector.rend(), le_sqrt_n);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've try to compile this code: #include <iostream> #include <cstdlib> using namespace std; #define
When I try to compile this code: #include <windows.h> namespace cmb1 { } void
when I try to compile this code: #include <boost/filesystem/path.hpp> #include <boost/filesystem/fstream.hpp> using namespace std;
When I try to compile this: #include <map> #include <string> template <class T> class
I try to compile this answer related to how to store functional objects with
When I try to compile this code: struct BasicVertexProperties { Vect3Df position; }; struct
When I try to compile this: import java.awt.* ; class obj { public static
When I try to compile this: public static Rand searchCount (int[] x) { int
When i try to compile this: public static int compareCardhl (Card c1, Card c2)
When I try to compile this project I get the following error. I would

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.