Giter VIP home page Giter VIP logo

Comments (5)

krzysztof-jusiak avatar krzysztof-jusiak commented on August 24, 2024

Hmm, isn't the case that you are just missing the capture of i?

The following works just fine with MSVC 👍

int main() {
  using namespace boost::ut;
  "example_test"_test = [] {
    constexpr std::array<int, 1> i{10};
    expect(nothrow([i] { return i.front(); }));
  };
}

Full example -> https://godbolt.org/z/PMYVyk

Alternatively, you can make it static too if it's constant 🤔

int main() {
  using namespace boost::ut;
  "example_test"_test = [] {
    static constexpr std::array<int, 1> i{10};
    expect(nothrow([] { return i.front(); }));
  };
}

Full example -> https://godbolt.org/z/TVJJPE

Please let me know if I misunderstood your issue, thanks @jwillikers 👍

from ut.

jwillikers avatar jwillikers commented on August 24, 2024

Thanks @krzysztof-jusiak. I must have some misunderstanding of lambda captures here. Why does your first example work given i explicitly in the capture but not work when using the generic = or & captures?

from ut.

krzysztof-jusiak avatar krzysztof-jusiak commented on August 24, 2024

Capturing using = should work as well and it does in gcc/clang, so it seems like MSVC issue 🐛

from ut.

jwillikers avatar jwillikers commented on August 24, 2024

@krzysztof-jusiak Thanks for your help! I found a bug report for the Visual C++ Compiler here which seems to capture this issue and it looks like the fix is complete and will be in an upcoming release. Thanks again for all your help 😀😀😀

from ut.

krzysztof-jusiak avatar krzysztof-jusiak commented on August 24, 2024

Nice @jwillikers, thanks for following it up and the link 👍

from ut.

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.