Code Monkey home page Code Monkey logo

Comments (5)

gnzlbg avatar gnzlbg commented on August 25, 2024

D style ranges can be used to iterate over things like std::tuple or other sequences that have varying types.

They might offer the same API for heterogeneous containers as for homogeneous run-time containers (like Fusion/STL), but is the algorithm implementation the same for heterogeneous sequences and run-time sequences?

These can't be implemented using C++ iterators without losing type information.

IIRC Boost.Fusion has "iterators" (besides "ranges") that do work on heterogeneous sequences. They are just a different type of iterators (and "ranges"). From an API pov, they work very similarly tho, and one can map knowledge from Boost.Range to Boost.Fusion and viceversa (which i think is the important thing).

Offering the same API for "everything" is appealing, and Boost.Hana actually does that, it works on type-only (mpl::vector), heterogeneous (std::tuple), and homogeneous (std::vector) sequences. However, even tho it could be possible to efficiently handle homogeneous run-time sequences in Hana, I believe one would have to specialize its algorithms for these sequences. The API could be the same, but the implementation would be very different, so one ends up with one API, but internally two different library implementations (just like Fusion/STL). Note that this is directly opposed to how Hana algorithms work on both type-only and heterogeneous sequences.

from range-v3.

ericniebler avatar ericniebler commented on August 25, 2024

D style ranges can be used to iterate over things like std::tuple or other sequences that have varying types.

They can? Where does it say that? What is the return type of the range's front property? It can't change type dynamically, can it?

from range-v3.

ericniebler avatar ericniebler commented on August 25, 2024

But wouldn't the D range have a == that would satisfy this requirements? Or perhaps have a front_equal and back_equal, since a D range can refer to two positions?

You can test if two D ranges are equal, but that's not a positional comparison. It tests the values of the elements. What I said is true: D ranges are not positional.

from range-v3.

ericniebler avatar ericniebler commented on August 25, 2024

Closing this, unless you have something else to say on the matter, @pfultz2.

from range-v3.

pfultz2 avatar pfultz2 commented on August 25, 2024

Sorry for the late reply.

They can? Where does it say that? What is the return type of the range's front property? It can't change type dynamically, can it?

I assume every time you call pop it returns a new range, so for each range front can return a different type, but I am not entirely familiar with D.

from range-v3.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.