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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:16:07+00:00 2026-05-23T23:16:07+00:00

The following code doesn’t compile in C++Builder 2009 or in Visual C++ 2005 when

  • 0

The following code doesn’t compile in C++Builder 2009 or in Visual C++ 2005 when the macro _HAS_ITERATOR_DEBUGGING equals 1 but if commented out it will. It appears the lower_bound function isn’t spec compliant. The library is swapping the arguments. Here’s an excerpt form the spec. value should always be the second argument. Am I wrong?

NOTE: The test code wasn’t designed to run. It was designed to illustrate the library bug.

C++ Spec excerpt

template<class ForwardIterator, class T, class Compare>
ForwardIterator
lower_bound(ForwardIterator first, 
            ForwardIterator last, 
            const T& value, 
            Compare comp);

25.3.3.1.3

Returns: The furthermost iterator i in the range [first, last] such that for any iterator j in the range [first, i) the following corresponding conditions hold: *j < value or comp(*j, value) != false

Visual Studio error message

Msg: error C2664: ‘double mike::operator ()(const double,const char *) const’ : cannot convert parameter 1 from ‘const char [1]’ to ‘const double’

File: c:\program files\microsoft visual studio 8\vc\include\xutility

Line No: 314

Test Code

#define _HAS_ITERATOR_DEBUGGING 1  // needs to be in the stdafx.h file for Visual Studio
#include "stdafx.h"
#include <algorithm>
#include <functional>

struct mike : public std::binary_function<double, char*, double> {
   double operator() (const double i, const char*) const {
      return i;
   }
};

int main()
{
   double r[] = {0};
   std::lower_bound(r, r, "", mike());
   return 0;
}
  • 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-23T23:16:08+00:00Added an answer on May 23, 2026 at 11:16 pm

    This is a known issue in the Visual C++ 2005 C++ Standard Library implementation (see “Binary predicate paramter to lower_bound assumes that both parameters are the same type when compiling in debug mode” on Microsoft Connect).

    The bug was fixed in Visual C++ 2008.

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

Sidebar

Related Questions

No related questions found

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.