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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T04:53:11+00:00 2026-05-20T04:53:11+00:00

I was reading another question, and it got me thinking. Often the standard specifies

  • 0

I was reading another question, and it got me thinking. Often the standard specifies functions which have default parameters in their descriptions. Does the standard allow writing these as overloads instead?

For example, the standard says that std::basic_string::copy has the following declaration:

size_type copy(Ch* p, size_type n, size_type pos = 0) const;

Could a conforming implementation of the standard library implement this instead as two functions like this?

size_type copy(Ch* p, size_type n, size_type pos) const;
size_type copy(Ch* p, size_type n) const;

In this example, the second version could skip the if(pos > size()) { throw out_of_range(); } test that is necessary in the first one. A micro-optimization, but still you see the point of the example.

  • 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-20T04:53:12+00:00Added an answer on May 20, 2026 at 4:53 am

    Could a conforming implementation of the standard library implement this instead as two functions like this?

    Yes. The C++ Standard (C++03 17.4.4.4/2-3) says:

    An implementation can declare additional non-virtual member function signatures within a [Standard Library] class:

    — by adding arguments with default values to a member function signature; the same latitude does not extend to the implementation of virtual or global or non-member functions, however.

    — by replacing a member function signature with default values by two or more member function signatures with equivalent behavior;

    — by adding a member function signature for a member function name.

    A call to a member function signature described in the C + + Standard library behaves the same as if the implementation declares no additional member function signatures

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

Sidebar

Related Questions

I was just reading another question about jQuery's synchronous ajax call, and I got
I've got another question with List of lists. Once again, I have the generic
I was reading another question pertaining the efficiency of two lines of code, and
While reading through another question here, on creating a URL shortening service, it was
In another question, the accepted answer shows a method for reading the contents of
im reading Practical common Lisp as a result of another question . I just
Sorry, another super basic ASP.NET question. this so embarrassing. I am reading the article
Y.A.N.Q. (yet another n00b question). I have managed to design my db, defining tables
I was reading the answers to this question C++ pros and cons and got
I've got a PHP application which needs to grab the contents from another web

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.