Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Runtime support for searchables #456

Open
jupp0r opened this issue Aug 6, 2019 · 0 comments
Open

Runtime support for searchables #456

jupp0r opened this issue Aug 6, 2019 · 0 comments

Comments

@jupp0r
Copy link

jupp0r commented Aug 6, 2019

This doesn't compile

#include <boost/hana.hpp>
#include <boost/hana/ext/std/tuple.hpp>
#include <boost/optional.hpp>

bool f() {
    auto t = std::make_tuple(boost::optional<int>{boost::none}, boost::optional<int>{4});
    return boost::hana::all(t);
}

This does, but not under MSVC (it rightfully complains that the lambda passed to all_of needs to return a Logical.

#include <boost/hana.hpp>
#include <boost/hana/ext/std/tuple.hpp>
#include <boost/optional.hpp>

bool f() {
    auto t = std::make_tuple(boost::optional<int>{boost::none}, boost::optional<int>{4});
    return boost::hana::all_of(t, [](auto v) { return static_cast<bool>(v); });
}

This compiles everywhere, but is suboptimal due to lack of early return:

#include <boost/hana.hpp>
#include <boost/hana/ext/std/tuple.hpp>
#include <boost/optional.hpp>

bool f() {
    auto t = std::make_tuple(boost::optional<int>{boost::none}, boost::optional<int>{4});
    return boost::hana::fold(t, true, [](bool state, auto v) {
        return state && static_cast<bool>(v);
    });
}

Reading through the documentation, I couldn't find any information about runtime support of algorithms. Is this a bug or an expected limitation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant