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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:15:59+00:00 2026-06-06T10:15:59+00:00

I always wondered why there is no sort(v);// same as std::sort(v.begin(),v.end()) If I recall

  • 0

I always wondered why there is no

sort(v);// same as std::sort(v.begin(),v.end())

If I recall correctly long time ago I saw a boostcon clip where speaker said that concepts are required for this, but I dont see why.
BTW I tried this (in VS 11) and it works niceli from what I can see.

template <typename Container>
void sortfx(Container& c)
{
    std::sort(c.begin(),c.end());
}
int main()
{

    std::vector<double> v;
    //std::list<double> v; this causes compile errors
    v.push_back(1701);
    v.push_back(1729);
    v.push_back(74656);
    v.push_back(2063);
    sortfx(v);
    assert(std::is_sorted(begin(v),end(v)));

}

EDIT:
Bjarne himself explains the concepts, with sort as an example 🙂
https://www.informit.com/articles/article.aspx?p=2080042&WT.rss_f=Article&WT.rss_a=An%20Interview%20with%20Bjarne%20Stroustrup&WT.rss_ev=a

  • 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-06T10:16:00+00:00Added an answer on June 6, 2026 at 10:16 am

    It’s not the std::sort(v) -> std::sort(v.begin(), v.end()) expansion that would need concepts, but the alternate sort function taking an additional parameter for the comparison – std::sort(v.begin(), v.end(), compare).

    If you have a call std::sort(v, compare), the implementation would need concepts to distinguish it from std::sort(start, end) for a non-container.

    The <algorithm> header is full of templates with this kind of problem.

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

Sidebar

Related Questions

I've always wondered is there a better way that I should be writing some
I've always wondered, lets say you have two asp.net websites running in the same
I've used emacs for decades and always wondered, but kept on coding, if there
I have always sort of wondered when to use a UIView vs. a UIViewController
I always wondered why there's an equals keyword in linq joins rather than using
I'v always wondered this. In a game like GTA where there are 10s of
I've been using spring for some time, but I always wondered how does it
I always wondered why there exists no removeParameters() method in Servlet API. What could
I always wondered: Are there any hard facts which would indicate that either shorter
Ive always wondered this but never had the chance to research it. What sort

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.