Giter VIP home page Giter VIP logo

Comments (5)

danakj avatar danakj commented on May 27, 2024

std::convertible_to still is used for templated function parameters in place of std::same_as.

We could provide our own version of the concept but it's not clear if that would add value, if it would check anything extra or the name could make things more clear.

It's only needed for templated function parameters since they don't convert automatically, and this makes them simply act like a normal function's parameter. I don't think we need to do a bunch of weird things just to make templated function parameters act differently, or act the same in a different way.

from subspace.

danakj avatar danakj commented on May 27, 2024

#164 addresses the points here.

  1. Done: We have Default as a concept and it's just about default constructors. with_default() have all been removed.
  2. Was already done. We have Copy and Move as concepts.
  3. Was already done. We use constructor methods instead of constructors when there are any arguments to them (other than copy/move).
  4. Done: We implemented SameOrSubclassOf to help with pointer upcast relationships, and we removed all is_convertible and is_constructible for that.

We are left with std::convertible_to concept which we use to make templated function parameters behave normally.

from subspace.

danakj avatar danakj commented on May 27, 2024

Lastly, to deal with the sad lack of CTAD with constructor methods (3), we are adding free function constructor shorthands that make a Marker type holding the arguments as references, and which can be used to construct the type.

Examples:

  • sus::option::some(x) -> SomeMarker { x }
  • sus::option::none() -> NoneMarker
  • sus::result::ok(x) -> OkMarker { x }
  • sus::result::err(x) -> ErrMarker { x }

We should also add some for other types like:

  • sus::containers::array()
  • sus::containers::vec()
  • sus::tuple::tuple()
  • sus::union_type::union... oh no. Maybe we should rename to choice if it will make this nicer. Let's see if this helper function can even exist and be useful, it should be able to... with a template param for the tag value.

Currently these are implemented by adding constructors to the types, but it should work to use operators that call the public constructors?

from subspace.

danakj avatar danakj commented on May 27, 2024

Ok, now we have the Marker types construct through the public APIs of the types instead of polluting those APIs with constructors from Markers.

Remaining to do here is add some more constructor functions + Marker types as per #125 (comment).

from subspace.

danakj avatar danakj commented on May 27, 2024

sus::union_type::union... oh no. Maybe we should #127 if it will make this nicer. Let's see if this helper function can even exist and be useful, it should be able to... with a template param for the tag value.

Ok well the function is writable and is useful: 090435e So I guess we should do the rename.

from subspace.

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.