From abe9fa26276c6c758aca7cee9cfc367ebe58017f Mon Sep 17 00:00:00 2001 From: Kris Jusiak Date: Fri, 1 Mar 2024 04:47:09 -0600 Subject: [PATCH] :new: mp --- .clang-format | 3 - .gitignore | 2 - .gitmodules | 3 - mp | 737 ++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 737 insertions(+), 8 deletions(-) delete mode 100644 .clang-format delete mode 100644 .gitignore delete mode 100644 .gitmodules create mode 100644 mp diff --git a/.clang-format b/.clang-format deleted file mode 100644 index 69ae7a7..0000000 --- a/.clang-format +++ /dev/null @@ -1,3 +0,0 @@ -Language: Cpp -Standard: Cpp11 -BasedOnStyle: Google diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 472d44b..0000000 --- a/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -build* -*metabench diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 04ff125..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "vendor/ut"] - path = vendor/ut - url = https://github.com/boost-ext/ut.git diff --git a/mp b/mp new file mode 100644 index 0000000..c590a29 --- /dev/null +++ b/mp @@ -0,0 +1,737 @@ +// +// Copyright (c) 2022-2024 Kris Jusiak (kris at jusiak dot net) +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +#if not defined(BOOST_MP_VERSION) +#define BOOST_MP_VERSION 1'0'0 + +#include +#include +#include +#include +#include +#include +#include + +namespace mp::inline v1_0_0 { +namespace utility { +#if __has_builtin(__type_pack_element) +template +using nth_pack_element = __type_pack_element; + +template +constexpr auto nth_pack_element_v = + __type_pack_element...>::value; +#else +namespace detail { +template +struct any {}; +template +struct inherit : Ts... {}; +template +auto nth_pack_element_impl(any) -> T; +template +auto nth_pack_element(std::index_sequence) + -> decltype(nth_pack_element_impl( + inherit, Ns>...>{})); +} // namespace detail + +template +using nth_pack_element = typename decltype(detail::nth_pack_element( + std::make_index_sequence{}))::type; + +template +constexpr auto nth_pack_element_v = + nth_pack_element...>::value; +#endif + +template +struct integral_constant : std::integral_constant { + [[nodiscard]] constexpr auto operator+(const auto value) const { + return integral_constant{}; + } + [[nodiscard]] constexpr auto operator-(const auto value) const { + return integral_constant{}; + } + [[nodiscard]] constexpr auto operator*(const auto value) const { + return integral_constant{}; + } + [[nodiscard]] constexpr auto operator/(const auto value) const { + return integral_constant{}; + } +}; + +template +[[nodiscard]] consteval auto operator""_c() { + return integral_constant<[] { + std::size_t result{}; + for (const auto c : std::array{Cs...}) { + result = result * std::size_t(10) + std::size_t(c - '0'); + } + return result; + }()>{}; +} +} // namespace utility + +namespace concepts { +namespace detail { +template +constexpr auto meta = false; +template