Coder Social home page Coder Social logo

codeinred / recursive-variant Goto Github PK

View Code? Open in Web Editor NEW
79.0 3.0 3.0 556 KB

Recursive Variant: A simple library for Recursive Variant Types

License: Other

CMake 42.13% C++ 57.87%
variants variant sum-types recursion recursive-types cpp cpp20 header-only header-only-library functional-programming

recursive-variant's Issues

Problem with std::pair<..., rva::self_t> - explicitly OR when using std::map<..., rva::self_t>

Having a great time with rva::variant - thanks! - as long as I only had a std::vector with a recursive reference.

Now that I am - possibly humorously, given your motivating sample - implementing a "JSON" value type, I run into trouble trying to build iff I include the "map" recursive reference mentioned above... this is with VS 2022 17.6.4 in C++20 language mode.

What happens is we get nailed on your line 38/39

constexpr static bool
nothrow_swappable = std::is_nothrow_swappable_v<base_type>;

... with the complaint that [effectively] base_type is undefined - even though you have just defined it on the previous line with some of your "replace" magic. :( As I mention in the issue title, this happens with either map or pair, as the actual problem is in pair, but map uses pairs etc.

I can, of course, make the build complete if I just remove the above constexpr static - and the single use in the definition of rva::variant::swap - But That Would Be Wrong(tm), not to mention having the noexcept-ness wrong one way or the other. ;)

Any ideas/suggestions/comments?

For anyone that finds this, I am adding a comment on my issue: just removing the "offending" declaration of the constexpr value nothrow_swappable seems to solve the compile problem, i.e., just plug the std::is_nothrow_swappable_v<base_type> directly in as the value of the noexcept expression in the definition of "swap".

can we change it to support define a List?

For example, a list can be defined in Haskell as List a = Nil | Cons a (List a), can we support it by changing std::tuple and std::variant? Going a step further, can we do it at zero cost?

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.