Questions tagged [boost-hana]

Boost.Hana is a C++14-based metaprogramming library. It provides high level algorithms to manipulate heterogeneous sequences, allows writing type-level computations with a natural syntax, provides tools to introspect user-defined types and much more.

Boost.Hana is a C++14-based metaprogramming library. It provides high level algorithms to manipulate heterogeneous sequences, allows writing type-level computations with a natural syntax, provides tools to introspect user-defined types and much more.

190 questions
0
votes
2 answers

Ordering multiple function calls during compile time

I have a function: template auto CallItemsInOrder(std::tuple items) { // Magic here! } Where each item of the tuple has two qualities: A priority for which it should be called, and a function overload to call it…
0
votes
1 answer

C++: efficient compile-time looping and Boost::hana::while_() runtime cost

Problem statement I have been experimenting with strategies to resolve loops at compile time with C++. The algorithmic problem I aim to solve is as follows: given integer 4-tuple I = (i1,i2,i3,i4) all between 0 and 3(d-1) such that i1+i2+i3+i4 =…
0
votes
1 answer

What is the maximum number of elements I can put in BOOST_HANA_ADAPT_STRUCT

When there are fewer elements in BOOST_HANA_ADAPT_STRUCT, such as 30 elements, there is no problem in compilation. But once it exceeds a certain number, the compilation prompts errors about every field within the BOOST_HANA_ADAPT_STRUCT has not been…
0
votes
1 answer

What is the advantage of Hana's type_c-and-declval dance when querying whether a SFINAE-friendly expression is valid?

On the one hand, the function boost::hana::is_valid is presented as follows Checks whether a SFINAE-friendly expression is valid. Given a SFINAE-friendly function, is_valid returns whether the function call is valid with the given arguments.…
Enlico
  • 23,259
  • 6
  • 48
  • 102
0
votes
0 answers

Using boost::hana to check for method existence

I'm trying to create a templated function contains that works for any container by trying these two steps: Using the container's own find method .find(value) if it exists (which should be optimized for that specific container) Using…
TesX
  • 931
  • 1
  • 9
  • 29
0
votes
1 answer

Boost hana first successful sfinae

I'd like to execute the first lambda in a list of lambdas, which isn't sfinaed out with boost hana. I have succeeded doing that with hana::if_ but that doesn't scale to any number of lambdas. I think I want lazy evaluation of find_if but I don't…
Jan15
  • 499
  • 3
  • 11
0
votes
2 answers

GENERIC solution for replacing if constexpr in C++14

Firstly, I have already seen Constexpr if alternative, but that didn't help. I updated the post to clarify explicitly the necessity of the generic solution. What I need is a generic solution to use the potential of C++17 if constexpr in C++14.…
0
votes
1 answer

What does boost::hana::always do more than just "always return its first argument"?

At the doc page of boost::hana::always I read that always(x) is a function such that always(x)(y...) == x for any y.... This makes me think that it shouldn't behave any differently than this lambda: [](auto const&...){ return false; }. However it…
Enlico
  • 23,259
  • 6
  • 48
  • 102
0
votes
1 answer

Perfect Forwarding for Lambda Chaining

I want to chain/compose multiple lambdas to a new lambda. When calling the new lambda with parameters it should call the original lambdas with these parameters. This lambda chaining does work well when the parameters are just copied but when I want…
erikzenker
  • 752
  • 5
  • 18
0
votes
0 answers

BOOST::HANA get all member names and iterate

Coming from a Java/C# background and as a BOOST newbie, I have difficulty in getting a list of the class members. I have the following struct/class. class Configurations { public: …
Wajih
  • 793
  • 3
  • 14
  • 31
0
votes
1 answer

boost::hana::is_valid fails to compile with gcc8 (and more) and --std=c++14

I use this code with std=c++14 and gcc7.3: #include #include #include #include #include #include namespace hana = boost::hana; template
0
votes
2 answers

Why do I get unexpected index when looping a boost::hana::tuple

Here is my code using my_variant = std::variant; auto my_types_map = hana::make_tuple( hana::make_pair(hana::type_c, hana::integral_c), hana::make_pair(hana::type_c, …
Reza
  • 360
  • 3
  • 17
0
votes
1 answer

How to transform a boost::hana::map into lambdas

I have the following code template void my_func(T& /*var*/) { }; auto my_types = hana::make_map( hana::make_pair(hana::type_c, hana::integral_c), hana::make_pair(hana::type_c,…
Reza
  • 360
  • 3
  • 17
0
votes
3 answers

How to convert a boost::hana::tuple into a std::variant

I have the following code where I want to convert a boost::hana::tuple into a std::variant namespace hana = boost::hana; template struct to_variant; template struct to_variant> { using type =…
Reza
  • 360
  • 3
  • 17
0
votes
1 answer

Apply a runtime function only when the runtime input equals a named member in a set of types

I have a hana tuple of types auto mytypes =\ bh::make_tuple(bh::type_c, bh::type_c, bh::type_c, bh::type_c); Each of the T are simple C++ structs. They all have a member static const std::string…
MMM
  • 910
  • 1
  • 9
  • 25
1 2 3
12
13