Giter Club home page Giter Club logo

Comments (3)

joboccara avatar joboccara commented on September 28, 2024

I think there are several ways:

Do you think either one of these solutions would allow to write the code you had in mind?

from namedtype.

Raikiri avatar Raikiri commented on September 28, 2024

Yes, both of them achieve exactly what I had in mind, however, implementation-wise, inheriting from an stl container is generally not a great practice.

from namedtype.

stellarpower avatar stellarpower commented on September 28, 2024

FWIW, some sort of half-automatic proxy wrapper might be great. I was hoping to combine this library with a units library, so that we have both semantic types, and correct phyiscal units/dimensions in our code. And all this would need to operate with matrix, vector, and quaternion types - quite a bit to juggle! So far, NamedType wrapping around boost::qvm is working quite nicely, albeit without the units support. This'll likely need some sort of proxy wrapper. We also have some Mats from OpenCV. This would be one example where being able to index into an opaque structure would be really powerful, if it could be done. QVM is so-designed that it's working nicely enough to have the NamedTypoe on the outside, as QVM is designed explicitly to operate on different (incompatible) types, and is thus mostly free-functions. But CV's Mat would not be so easy, and was one justifying reason for moving away from it and using this lib - access is always risky and very much relies on runtime support, including the type of data it's storing. It's all held behind one single type.

Tl;Dr - I imagine a composition proxy wrapper might work quite powerfully here - a more generic version of the reference version above, I guess - perhaps using some specialised traits to define how to access the wrapped object, with some sensible automatic defaults, like for operator[]. And if done well, I'd hope it would compile away to the same binary format, a bit like how std::chrono evaporates after build-time, and I believe NamedType itself does. Perhaps NamedContainer<Key, Value>, for a rough way of accessing - for things like list and vector, the key becomes more of an index. Am guessing map and set will work as-is, although may be wrong.

from namedtype.

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.