A modern C++ 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
Your standard library for metaprogramming
Overview
#include <boost/hana.hpp>
#include <cassert>
#include <string>
namespace hana = boost::hana;
using namespace hana::literals;
struct Fish { std::string name; };
struct Cat { std::string name; };
struct Dog { std::string name; };
int main() {
// Sequences capable of holding heterogeneous objects, and algorithms
// to manipulate them.
auto animals = hana::make_tuple(Fish{"Nemo"}, Cat{"Garfield"}, Dog{"Snoopy"});
auto names = hana::transform(animals, [](auto a) {
return a.name;
});
assert(hana::reverse(names) == hana::make_tuple("Snoopy", "Garfield", "Nemo"));
// No compile-time information is lost: even if `animals` can't be a
// constant expression because it contains strings, its length is constexpr.
static_assert(hana::length(animals) == 3u, "");
// Computations on types can be performed with the same syntax as that of
// normal C++. Believe it or not, everything is done at compile-time.
auto animal_types = hana::make_tuple(hana::type_c<Fish*>, hana::type_c<Cat&>, hana::type_c<Dog*>);
auto animal_ptrs = hana::filter(animal_types, [](auto a) {
return hana::traits::is_pointer(a);
});
static_assert(animal_ptrs == hana::make_tuple(hana::type_c<Fish*>, hana::type_c<Dog*>), "");
// And many other goodies to make your life easier, including:
// 1. Access to elements in a tuple with a sane syntax.
static_assert(animal_ptrs[0_c] == hana::type_c<Fish*>, "");
static_assert(animal_ptrs[1_c] == hana::type_c<Dog*>, "");
// 2. Unroll loops at compile-time without hassle.
std::string s;
hana::int_c<10>.times([&]{ s += "x"; });
// equivalent to s += "x"; s += "x"; ... s += "x";
// 3. Easily check whether an expression is valid.
// This is usually achieved with complex SFINAE-based tricks.
auto has_name = hana::is_valid([](auto&& x) -> decltype((void)x.name) { });
static_assert(has_name(animals[0_c]), "");
static_assert(!has_name(1), "");
}
Depends (5)
Builds
toolchain |
public-0.16.0 |
target |
x86_64-apple-darwin22.5.0 |
tgt config |
macos_13-clang_14.0-static_O3 |
timestamp |
2024-03-28 13:44:14 UTC (16:58:44 hours ago) |
result |
warning (update) | warning (test-installed) | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-apple-darwin22.5.0 |
tgt config |
macos_13-clang_14.0-O3 |
timestamp |
2024-03-28 13:41:08 UTC (17:01:50 hours ago) |
result |
warning (update) | warning (test-installed) | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-apple-darwin22.5.0 |
tgt config |
macos_13-clang_14.0 |
timestamp |
2024-03-28 13:38:44 UTC (17:04:14 hours ago) |
result |
warning (update) | warning (test-installed) | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-apple-darwin22.5.0 |
tgt config |
macos_13-clang_15.0-static_O3 |
timestamp |
2024-03-27 21:37:32 UTC (01 09:05:26 days ago) |
result |
warning (update) | warning (test-installed) | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-apple-darwin22.5.0 |
tgt config |
macos_13-clang_15.0-O3 |
timestamp |
2024-03-27 21:34:52 UTC (01 09:08:07 days ago) |
result |
warning (update) | warning (test-installed) | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-apple-darwin22.5.0 |
tgt config |
macos_13-clang_15.0 |
timestamp |
2024-03-27 21:32:12 UTC (01 09:10:47 days ago) |
result |
warning (update) | warning (test-installed) | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-linux-gnu |
tgt config |
linux_fedora_37-gcc_12.2-bindist |
timestamp |
2024-03-27 19:50:13 UTC (01 10:52:45 days ago) |
result |
success | log | rebuild |
toolchain |
public-0.16.0 |
target |
aarch64-linux-gnu |
tgt config |
linux_debian_12-clang_16_libc++-static_O3 |
timestamp |
2024-03-27 14:56:45 UTC (01 15:46:13 days ago) |
result |
warning (update) | warning (test-installed) | log | rebuild |
toolchain |
public-0.16.0 |
target |
aarch64-linux-gnu |
tgt config |
linux_debian_12-clang_16_libc++-O3 |
timestamp |
2024-03-27 14:51:27 UTC (01 15:51:31 days ago) |
result |
warning (update) | warning (test-installed) | log | rebuild |
toolchain |
public-0.16.0 |
target |
aarch64-linux-gnu |
tgt config |
linux_debian_12-clang_16_libc++ |
timestamp |
2024-03-27 14:51:23 UTC (01 15:51:35 days ago) |
result |
warning (update) | warning (test-installed) | log | rebuild |
toolchain |
public-0.16.0 |
target |
aarch64-linux-gnu |
tgt config |
linux_debian_12-clang_16-static_O3 |
timestamp |
2024-03-27 14:49:29 UTC (01 15:53:30 days ago) |
result |
warning (update) | warning (test-installed) | log | rebuild |
toolchain |
public-0.16.0 |
target |
aarch64-linux-gnu |
tgt config |
linux_debian_12-clang_16 |
timestamp |
2024-03-27 14:49:15 UTC (01 15:53:44 days ago) |
result |
warning (update) | warning (test-installed) | log | rebuild |
toolchain |
public-0.16.0 |
target |
aarch64-linux-gnu |
tgt config |
linux_debian_12-clang_16-O3 |
timestamp |
2024-03-27 14:46:03 UTC (01 15:56:56 days ago) |
result |
warning (update) | warning (test-installed) | log | rebuild |
toolchain |
public-0.16.0 |
target |
aarch64-linux-gnu |
tgt config |
linux_debian_12-gcc_13-ndebug_O3 |
timestamp |
2024-03-27 12:41:50 UTC (01 18:01:08 days ago) |
result |
warning (update) | warning (test-installed) | log | rebuild |
toolchain |
public-0.16.0 |
target |
aarch64-linux-gnu |
tgt config |
linux_debian_12-gcc_13-static_O3 |
timestamp |
2024-03-27 12:39:33 UTC (01 18:03:25 days ago) |
result |
warning (update) | warning (test-installed) | log | rebuild |
toolchain |
public-0.16.0 |
target |
aarch64-linux-gnu |
tgt config |
linux_debian_12-gcc_13 |
timestamp |
2024-03-27 12:37:17 UTC (01 18:05:41 days ago) |
result |
warning (update) | warning (test-installed) | log | rebuild |
toolchain |
public-0.16.0 |
target |
aarch64-linux-gnu |
tgt config |
linux_debian_12-gcc_13-O3 |
timestamp |
2024-03-27 12:36:30 UTC (01 18:06:29 days ago) |
result |
warning (update) | warning (test-installed) | log | rebuild |
toolchain |
public-0.16.0 |
target |
aarch64-linux-gnu |
tgt config |
linux_debian_11-gcc_12 |
timestamp |
2024-03-27 09:09:03 UTC (01 21:33:56 days ago) |
result |
success | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-linux-gnu |
tgt config |
linux_debian_12-gcc_12-bindist |
timestamp |
2024-03-27 08:18:27 UTC (01 22:24:31 days ago) |
result |
success | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-microsoft-win32-msvc14.3 |
tgt config |
windows_10-msvc_17.6-static_O2 |
timestamp |
2024-03-27 03:44:03 UTC (02 02:58:55 days ago) |
result |
success | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-microsoft-win32-msvc14.3 |
tgt config |
windows_10-msvc_17.6-O2 |
timestamp |
2024-03-27 03:42:20 UTC (02 03:00:38 days ago) |
result |
success | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-microsoft-win32-msvc14.3 |
tgt config |
windows_10-msvc_17.6 |
timestamp |
2024-03-27 03:39:57 UTC (02 03:03:01 days ago) |
result |
success | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-w64-mingw32 |
tgt config |
windows_10-gcc_12.2_mingw_w64-static_O2 |
timestamp |
2024-03-27 03:08:26 UTC (02 03:34:32 days ago) |
result |
success | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-w64-mingw32 |
tgt config |
windows_10-gcc_12.2_mingw_w64 |
timestamp |
2024-03-27 03:03:21 UTC (02 03:39:38 days ago) |
result |
success | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-w64-mingw32 |
tgt config |
windows_10-gcc_12.2_mingw_w64-O2 |
timestamp |
2024-03-27 03:02:11 UTC (02 03:40:47 days ago) |
result |
success | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-microsoft-win32-msvc14.3 |
tgt config |
windows_10-msvc_17.5 |
timestamp |
2024-03-27 02:46:50 UTC (02 03:56:08 days ago) |
result |
success | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-freebsd12.4 |
tgt config |
freebsd_12-clang_13.0 |
timestamp |
2024-03-27 02:18:18 UTC (02 04:24:40 days ago) |
result |
success | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-linux-gnu |
tgt config |
linux_debian_11-gcc_12.1 |
timestamp |
2024-03-27 02:11:48 UTC (02 04:31:10 days ago) |
result |
success | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-linux-gnu |
tgt config |
linux_fedora_38-gcc_13-bindist |
timestamp |
2024-03-27 00:56:06 UTC (02 05:46:52 days ago) |
result |
warning (update) | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-microsoft-win32-msvc14.3 |
tgt config |
windows_10-clang_16.0_llvm_msvc_17.6-O2 |
timestamp |
2024-03-26 20:40:47 UTC (02 10:02:11 days ago) |
result |
warning (update) | warning (test-installed) | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-microsoft-win32-msvc14.3 |
tgt config |
windows_10-clang_16.0_llvm_msvc_17.6-static_O2 |
timestamp |
2024-03-26 20:37:08 UTC (02 10:05:51 days ago) |
result |
warning (update) | warning (test-installed) | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-microsoft-win32-msvc14.3 |
tgt config |
windows_10-clang_16.0_llvm_msvc_17.6 |
timestamp |
2024-03-26 20:34:42 UTC (02 10:08:16 days ago) |
result |
warning (update) | warning (test-installed) | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-linux-gnu |
tgt config |
linux_debian_12-clang_16.0_libc++-O3 |
timestamp |
2024-03-26 20:28:36 UTC (02 10:14:23 days ago) |
result |
warning (update) | warning (test-installed) | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-linux-gnu |
tgt config |
linux_debian_12-clang_16.0_libc++-static_O3 |
timestamp |
2024-03-26 20:27:35 UTC (02 10:15:23 days ago) |
result |
warning (update) | warning (test-installed) | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-linux-gnu |
tgt config |
linux_debian_12-clang_16.0 |
timestamp |
2024-03-26 20:26:13 UTC (02 10:16:45 days ago) |
result |
warning (update) | warning (test-installed) | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-linux-gnu |
tgt config |
linux_debian_12-clang_16.0-static_O3 |
timestamp |
2024-03-26 20:25:56 UTC (02 10:17:02 days ago) |
result |
warning (update) | warning (test-installed) | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-linux-gnu |
tgt config |
linux_debian_12-clang_16.0_libc++ |
timestamp |
2024-03-26 20:25:05 UTC (02 10:17:53 days ago) |
result |
warning (update) | warning (test-installed) | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-linux-gnu |
tgt config |
linux_debian_12-clang_16.0-O3 |
timestamp |
2024-03-26 20:23:47 UTC (02 10:19:12 days ago) |
result |
warning (update) | warning (test-installed) | log | rebuild |
toolchain |
public-0.16.0 |
target |
aarch64-linux-gnu |
tgt config |
linux_debian_12-clang_15_libc++ |
timestamp |
2024-03-26 16:05:40 UTC (02 14:37:18 days ago) |
result |
warning (update) | warning (test-installed) | log | rebuild |
toolchain |
public-0.16.0 |
target |
aarch64-linux-gnu |
tgt config |
linux_debian_12-clang_15 |
timestamp |
2024-03-26 16:04:36 UTC (02 14:38:23 days ago) |
result |
warning (update) | warning (test-installed) | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-linux-gnu |
tgt config |
linux_debian_12-gcc_13.1 |
timestamp |
2024-03-26 13:33:53 UTC (02 17:09:06 days ago) |
result |
warning (update) | warning (test-installed) | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-linux-gnu |
tgt config |
linux_debian_12-gcc_13.1-O3 |
timestamp |
2024-03-26 13:33:14 UTC (02 17:09:44 days ago) |
result |
warning (update) | warning (test-installed) | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-linux-gnu |
tgt config |
linux_debian_12-gcc_13.1-ndebug_O3 |
timestamp |
2024-03-26 13:32:40 UTC (02 17:10:18 days ago) |
result |
warning (update) | warning (test-installed) | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-linux-gnu |
tgt config |
linux_debian_12-gcc_13.1-static_O3 |
timestamp |
2024-03-26 13:31:48 UTC (02 17:11:10 days ago) |
result |
warning (update) | warning (test-installed) | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-microsoft-win32-msvc14.3 |
tgt config |
windows_10-clang_15.0_msvc_msvc_17.6 |
timestamp |
2024-03-26 12:49:41 UTC (02 17:53:18 days ago) |
result |
warning (update) | warning (test-installed) | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-freebsd13.2 |
tgt config |
freebsd_13-clang_14.0 |
timestamp |
2024-03-26 12:36:08 UTC (02 18:06:51 days ago) |
result |
warning (update) | warning (test-installed) | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-linux-gnu |
tgt config |
linux_debian_12-clang_15.0_libc++ |
timestamp |
2024-03-26 12:21:34 UTC (02 18:21:24 days ago) |
result |
warning (update) | warning (test-installed) | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-freebsd13.2 |
tgt config |
freebsd_13-clang_14.0-O3 |
timestamp |
2024-03-26 12:20:43 UTC (02 18:22:15 days ago) |
result |
warning (update) | warning (test-installed) | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-linux-gnu |
tgt config |
linux_debian_12-clang_15.0 |
timestamp |
2024-03-26 12:19:33 UTC (02 18:23:25 days ago) |
result |
warning (update) | warning (test-installed) | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-freebsd13.2 |
tgt config |
freebsd_13-clang_14.0-static_O3 |
timestamp |
2024-03-26 12:19:16 UTC (02 18:23:43 days ago) |
result |
warning (update) | warning (test-installed) | log | rebuild |
target |
x86_64-apple-darwin22.5.0 |
tgt config |
macos_13-gcc_13_homebrew |
result |
excluded (https://github) |
target |
x86_64-apple-darwin22.5.0 |
tgt config |
macos_13-gcc_13_homebrew-O3 |
result |
excluded (https://github) |
target |
x86_64-apple-darwin22.5.0 |
tgt config |
macos_13-gcc_13_homebrew-static_O3 |
result |
excluded (https://github) |