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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:02:23+00:00 2026-05-23T11:02:23+00:00

Suppose we have two ranges r1 = [first1, last1) and r2 = [first2, last2)

  • 0

Suppose we have two ranges r1 = [first1, last1) and r2 = [first2, last2)

Let’s say that r2 is a subrange of r1 iff there exists such i>=0 that

  1. [first1 + i, first1 + i + last2 - first2) is a valid range

  2. for all j in [0, last2 - first2) the following holds:

    *(first1 + i + j) == *(first2 + j)
    

A nested loop can easily determine if r2 is a subrange of r1, or even one loop with a nested call to std::equal template. Is there a more STL-ish, concise way to express the same idea in C++? C++0x solutions are welcome, too. Thanks in advance.

  • 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-23T11:02:24+00:00Added an answer on May 23, 2026 at 11:02 am

    I think std::search is what you’re looking for. From http://www.cplusplus.com/reference/algorithm/search/ [std::search] “Searches the range [first1,last1) for the first occurrence of the sequence defined by [first2,last2), and returns an iterator to its first element.”

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

Sidebar

Related Questions

Let us suppose we have a number circle, that ranges from -180 to 180,
Suppose you have two seperate ASP.NET Web Application projects that both need to use
Suppose I have two classes that both contain a static variable, XmlTag. The second
Suppose you have two linked servers called Local and Remote respectively. Is there a
Suppose I have two tables that are linked (one has a foreign key to
Suppose I have two tables, table A and table B, and that table A
Suppose i have two methods in a class say public void eat(int i,String s)
Suppose I have two files, A and B, and that lengthOf(A) < lengthOf(B). Is
Suppose I have two versions v0.1 and v0.2. In between, there are about 20
let's say that I have this function in Rails (I have actually :P -

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.