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 <iostream> | |
| #include <utility> | |
| template <size_t I, class F> | |
| inline auto ct_value(F&& f) | |
| { | |
| return std::forward<F>(f)(std::integral_constant<size_t, I>()); | |
| } | |
| template <class F, size_t... I> |
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 <iostream> | |
| #include <iomanip> | |
| #include <tuple> | |
| // TODO fix alignment to match struct alignment | |
| // Empty list | |
| template <class...> | |
| struct seq_tuple | |
| { }; |
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 <boost/mp11/algorithm.hpp> | |
| namespace mp11 = boost::mp11; | |
| template<class... Ts> constexpr mp11::mp_list<Ts...> list{}; | |
| constexpr mp11::mp_quote<mp11::mp_unique> unique{}; | |
| template<class T> struct transform_ { template<class... Ts> using fn = mp11::mp_transform<T::template fn, Ts...>; }; | |
| template<class T> constexpr transform_<T> transform{}; |
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 <tuple> | |
| #include <type_traits> | |
| template <class T, class... TArgs> | |
| decltype(void(T{std::declval<TArgs>()...}), std::true_type{}) | |
| test_is_braces_constructible(int); | |
| template <class, class...> | |
| std::false_type | |
| test_is_braces_constructible(...); |
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
| #pragma once | |
| #include <tuple> | |
| #include <functional> | |
| // Remove indexes from std::index_sequence that | |
| // do not satisfy condition. | |
| template <template <size_t> class Cond, class Src, size_t... Fs> | |
| struct filter_index_sequence { | |
| using type = std::index_sequence<Fs...>; |
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 <iostream> | |
| #include <functional> | |
| #include <tuple> | |
| #include <type_traits> | |
| template <class T> | |
| struct fn_signature | |
| : fn_signature<decltype(std::function(std::declval<T>()))> | |
| { }; |
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
| // Adapted to Arduino devices (running C++14 with RTTI and exceptions disabled). | |
| // Vladimir Talybin (2021) | |
| // | |
| // Note! Since Arduino has exceptions disabled the implementation become much | |
| // simpler. All noexcept flags removed and no actions (in case exception throws) | |
| // for invalid state applied. | |
| // In case of invalid operation (like getting value of valueless variant) the | |
| // program will abort (call std::abort()). | |
| // | |
| // Removed: |
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
| #pragma once | |
| #include <utility> | |
| // Basic implementation of tuple | |
| template <class...> | |
| struct tuple; | |
| template <> | |
| struct tuple<> { }; |
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
| #pragma once | |
| #include <functional> | |
| #include <any> | |
| template <class T> | |
| struct fn_signature | |
| : fn_signature<decltype(std::function(std::declval<T>()))> | |
| { }; | |
| template <class T> |
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
| // Function signature of std::function or its callable target. | |
| // Works with gcc only, clang has no deduction guides for | |
| // std::function in its library (tested with clang 8.0). | |
| // However using -stdlib=libstdc++ should work. | |
| // https://godbolt.org/z/khLhes | |
| #pragma once | |
| #include <functional> | |
| template <class T> |