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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:08:20+00:00 2026-06-05T12:08:20+00:00

I cannot find any good documentation on how to use a range in conjunction

  • 0

I cannot find any good documentation on how to use a range in conjunction with a container. I’m trying to insert an element into a SList using the given .insertAfter() function. It takes a range though and I have no idea how to retrieve it.

Can someone please post an example or two of how to use this poorly documented feature?

This is the D documentation for containers – http://dlang.org/phobos/std_container.html

I’ve also read ranges can be used like c++ iterators. If this is true how can I use a range in a loop?

  • 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-05T12:08:23+00:00Added an answer on June 5, 2026 at 12:08 pm

    use the slice operator ([])to get the range of a container

    to iterate over a container you can do:

    foreach(el;container[]){
    
    }
    

    a range has a front property which is the element currently pointed at, the popFront of a range will move the range to the next element and empty will indicate whether the range is at the end

    the foreach loop above is equivalent to

    for(auto range=container[];!range.empty;range.popFront()){
        auto el = range.front;
    
    }
    

    to insert into the middle of the list you’ll need to do

    container.insertAfter(take(container[],5),element);
    

    to insert at the end it’s

    container.insertAfter(container[],element);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hardly can I find any good material on Poco C++. Their documentation cannot replace
i cannot find any documentation of this project
I'm missing something, but I cannot find any hint online. When I use Javascript's
I started playing around with Pascal Script today and I cannot find any good
I simply cannot find any good pedagogical ressource explaining suffix arrays. Even the bible
I did comprehensive Google research but I cannot find any good solution, so any
After googling extensively I cannot find any good resources on the practices / process
I'm trying to optimize my 'location' directives and cannot find a good way of
I encountered SYS#0 at the top of a stack and cannot find any documentation
I know that STL has a HashMap API, but I cannot find any good

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.