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

  • Home
  • SEARCH
  • 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 7839889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:35:13+00:00 2026-06-02T15:35:13+00:00

template <class T> struct greater : binary_function <T,T,bool> { bool operator() (const T& x,

  • 0
template <class T> struct greater : binary_function <T,T,bool> {
  bool operator() (const T& x, const T& y) const
    {return x>y;}
};

template <class T> struct logical_and : binary_function <T,T,bool> {
  bool operator() (const T& x, const T& y) const
    {return x&&y;}
};

// (i > 5 && i <=10)
countBoost = std::count_if(vecInts.begin(), vecInts.end(),
                           boost::bind(std::logical_and<bool>(), 
                                                        ^^^^ // ???? Why ????
                                    boost::bind(std::greater<int>(),    _1, 5),
                                    boost::bind(std::less_equal<int>(), _1, 10))
                          );

Based on my understanding, the pass-in type T for std::logical_and<T> is the type of the pass-in parameters of function operator(). Given the above code, it seems that the type of std::greater is bool that is determined by the returned value of operator().

Is that correct?

Thank you

  • 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-02T15:35:15+00:00Added an answer on June 2, 2026 at 3:35 pm

    The boost binder does a bit more magic than what you might be expecting. When one of the bound arguments is a bind expression itself, it will execute that expression during the call and use the result. In this case, the internal bound expressions are calls to std::less<int> and std::greater<int>, both of which yield a bool, which is then passed to the std::logical_and<bool>.

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

Sidebar

Related Questions

I have the following code: template <class T> struct pointer { operator pointer<const T>()
Given the following base class: struct ValueType { String ToString(String const& format) const; };
How can instantiate this template struct? template<typename T, template<typename, template <typename> class D= std::allocator
Suppose I have the following class template: template<typename T> struct Wrapper { T* t_;
I have a class like template <class T> struct A{ template <class U> A(U
Given: template<class T> struct test { void foo(int b); void testFunc( int a )
I have the following structure: template <class T> struct Array{ int lenght; T *
Is it possible to specialize this template for any basic_string's? template<class T> struct X
I have code: #include <cstdio> template<template<typename...> class> struct Foo { enum { n =
regarding my Point struct already mentioned here: template class: ctor against function -> new

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.