Coder Social home page Coder Social logo

Ranges and lambdas weirdness about stl HOT 4 CLOSED

samsinsane avatar samsinsane commented on August 16, 2024
Ranges and lambdas weirdness

from stl.

Comments (4)

cpplearner avatar cpplearner commented on August 16, 2024 1

filter requires a indirect_unary_predicate, which requires the predicate to be callable with different types of arguments, and return a boolean-testable type in each case.

As you correctly identified, calling the predicate with the iterator's value_type is checked by the concept, but is not executed. Call with a dereferenced iterator is checked and executed.

With -> bool, the lambda body is not instantiated when checking the return type, so the validity of std::get<A&>(el) is not checked by the concept.

Blame the authors of ranges-v3 for the design of indirect_unary_predicate :)

from stl.

StephanTLavavej avatar StephanTLavavej commented on August 16, 2024 1

On a related note, I just filed #4575 because the diagnostic for bogus get-by-type is very confusing.

from stl.

samsinsane avatar samsinsane commented on August 16, 2024

Thank you for the responses, really appreciate the time you both spent on this.

@StephanTLavavej @CaseyCarter If there's nothing else to be actioned on your end, I'm happy for this to be closed off.

from stl.

StephanTLavavej avatar StephanTLavavej commented on August 16, 2024

Sounds good to me! Casey offered to provide additional clarification if necessary but if you're happy then we're happy.

from stl.

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.