This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <utility> | |
#include <string> | |
#include <string_view> | |
using namespace std::literals; | |
// | |
template <class F, class... Args, | |
class = decltype(std::declval<F&&>()(std::declval<Args&&>()...))> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdint> | |
#include <algorithm> | |
#include <tuple> | |
template <class... Ts> | |
auto constexpr persist(Ts volatile... ts) | |
{ std::tuple{ ts... }; } | |
auto constexpr hamming_weight(std::uint16_t const mask, | |
std::uint16_t const value) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <utility> | |
#include <string> | |
#include <string_view> | |
using namespace std::literals; | |
// | |
auto constexpr checker(...) {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cassert> | |
#define auto_assert(...) \ | |
[](auto expression) \ | |
{ \ | |
if constexpr (noexcept(expression())) \ | |
{ static_assert(expression()); } \ | |
else \ | |
{ assert(expression()); } \ | |
} \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <utility> | |
#include <cstddef> | |
#include <array> | |
#include <type_traits> | |
// | |
template <class T, std::size_t Rows, std::size_t Cols = Rows> | |
struct matrix | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <utility> | |
#include <type_traits> | |
// | |
namespace detail | |
{ | |
template <auto I, class T> | |
struct indexer_elem | |
{}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstddef> | |
#include <type_traits> | |
// | |
template <auto V> | |
struct constant | |
{ | |
using value_type = decltype(V); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static auto constexpr less = [](auto&& l, auto&& r) { return l < r; }; | |
static auto constexpr less_equal = [](auto&& l, auto&& r) { return l <= r; }; | |
static auto constexpr greater = [](auto&& l, auto&& r) { return l > r; }; | |
static auto constexpr greater_equal = [](auto&& l, auto&& r) { return l <= r; }; | |
// | |
template <template <auto...> class C, auto... Vs, class Fn> | |
auto constexpr sort(C<Vs...> in, Fn) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <utility> | |
#include <string> | |
#include <string_view> | |
#include <type_traits> | |
using namespace std::literals; | |
#define version 17 | |
// C++11 solution |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <type_traits> | |
// | |
template <class...> | |
struct type_pack | |
{}; | |
// |