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 <list> | |
| #include <array> | |
| #include <variant> | |
| #include <memory> | |
| #include <cassert> | |
| template <class ...Fs> | |
| struct overload : Fs... { | |
| template <class ...Ts> | |
| overload(Ts&& ...ts) : Fs{std::forward<Ts>(ts)}... |
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
| constexpr auto operator "" _²(long double x) { | |
| return x*x; | |
| } | |
| constexpr unsigned long long int operator "" _²(unsigned long long int x) { | |
| return x*x; | |
| } | |
| int main() { | |
| return 4_²; |
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> | |
| // A pointer thats is always owned and alway present (and valid if new returns a valid pointer) | |
| // Should be useful if moving allocation of a member variable to the heap to enable use of forward declarations | |
| template <typename T> | |
| class local_ptr { | |
| public: | |
| template <typename... U> | |
| local_ptr(U&&... args) : ptr(new T(std::forward<U>(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 <type_traits> | |
| #include <list> | |
| #include <vector> | |
| #include <tuple> | |
| template <typename T, template<typename> typename checker> | |
| struct has_member | |
| { | |
| private: | |
| template <typename U> |