Code Monkey home page Code Monkey logo

Comments (4)

compiletime avatar compiletime commented on August 16, 2024

Here is a rough draft of short-circuiting a template instantiation:
https://gist.github.com/compiletime/5c30bc18f22582cbd9e9ebb3847776d6

@ldionne If this looks like the right approach to you, would you assign this issue to me?

from hana.

ldionne avatar ldionne commented on August 16, 2024

Thanks for looking at this. However, let me clarify what I meant when I opened this issue. What I meant was that it should be possible for the following to only ever instantiate the left hand side:

hana::true_c || hana::any_of(some-tuple, hana::equal.to(hana::type<int>{}))

In other words, I wanted the logical operators to have short-circuitting instantiation, just like they have short-circuitting evaluation at runtime. However, the problem is that in order to even resolve which operator|| should be called, both argument types obviously need to be instantiated. This leaves us with the only option of returning some lazy compile-time boolean from hana::any_of, so that operator|| only evaluates it when needed. However, this means that all the algorithms that return booleans would need to return that lazy boolean, and it would also require some level of interoperability with normal integral_constants. I'm not sure this can be achieved at all, frankly.

from hana.

compiletime avatar compiletime commented on August 16, 2024

Your intention is very clear now. I mistook it for short-circuiting the concept check.

from hana.

ldionne avatar ldionne commented on August 16, 2024

Sorry the issue was unclear at first. This was opened a long time ago when I was the only one looking at this :-). Anyway, I'll close this as I think this can't be implemented reasonably, and if constexpr in C++17 will make some of this a non-issue (since you can nest ifs instead of relying on logical short-circuiting).

from hana.

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.