Skip to content

Latest commit

 

History

History
52 lines (37 loc) · 1.16 KB

265.md

File metadata and controls

52 lines (37 loc) · 1.16 KB
Info

Example

constexpr auto foo = [] [[deprecated]] { };

int main() {
    foo(); // operator() is deprecated
}

https://godbolt.org/z/MaeTnG9eb

Puzzle

  • Can you implement variable template lambda expression foo which is marked nodiscard for integral types?
//TODO foo

int main() {
    using namespace boost::ut;

    "should be callable for non integral types"_test = [] {
        foo<float>();
        foo<double>();
    };

    "should verify the result for integral types"_test = [] {
        expect(0_c == foo<char>());
        expect(not foo<bool>());
        expect(0_s == foo<short>());
        expect(0_i == foo<int>());
    };

    "should ignore the result for integral types"_test = [] {
        /*TODO*/ foo<char>();
        /*TODO*/ foo<bool>();
        /*TODO*/ foo<short>();
        /*TODO*/ foo<int>();
    };
}

https://godbolt.org/z/fKfjsbWoh

Solutions