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
| #ifndef IS_CALLABLE_HXX | |
| #define IS_CALLABLE_HXX | |
| #include <functional> | |
| #include <tuple> | |
| template<class ...> | |
| using void_t = void; | |
| // In fact, operator() is defined for the standard functions, even if they are not objects. |
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
| #ifndef ALLOCATOR | |
| #define ALLOCATOR | |
| #include <MetaMinimal.hxx> | |
| #include <cstdlib> | |
| #include <limits> | |
| #include <type_traits> | |
| #include <utility> |
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
| #ifndef OBSERVER_PTR_HXX | |
| #define OBSERVER_PTR_HXX | |
| #include <functional> | |
| #include <type_traits> | |
| /* Basically only for "void_t". You might instead want to define it yourself as this is extremly simple : | |
| template<class ...> | |
| using void_t = void; |
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 <Meta.hxx> | |
| // Normally I use my little metaprogramming class, but it should be easy to adapt the code to use something better | |
| // (or maybe standard C++ when it got more metaprogramming features) | |
| // If you don't care, you can grab my little library here | |
| // https://gist.github.com/Redchards/c7a454adb151e79f4e9d | |
| template<class T> | |
| static constexpr bool is_empty_and_trivial = std::is_empty<T>::value && std::is_trivial<T>::value; | |
| 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
| namespace meta | |
| { | |
| template<class T> | |
| using invoke = typename T::type; | |
| template<class T> | |
| struct always | |
| { | |
| template<class ...> |
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
| #ifndef IS_CALLABLE_HXX | |
| #define IS_CALLABLE_HXX | |
| #include <functional> | |
| #include <tuple> | |
| template<class ...> | |
| using void_t = void; | |
| // In fact, operator() is defined for the standard functions, even if they are not objects. |
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
| namespace CTTI | |
| { | |
| template<class T> | |
| static const char* GetTypeName() | |
| { | |
| static constexpr size_t typeNameLength = sizeof(FUNCTION) - (exprBegin.size() + exprEnd.size()); | |
| static constexpr ConstString functionName = FUNCTION; | |
| static StackString<typeNameLength + 1> typeName(functionName.data() + exprBegin.size(), typeNameLength); | |
| return typeName; |
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
| // Inspired by http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3329.pdf | |
| // Unfortunatly, there is not way to implement the most interesting feature right now : the static if inside classes. | |
| // I didn't find a way to do this without ugly macro hacks, so we need to deal with it ... | |
| // Oh, and special mention to SuperV1234 (https://github.com/SuperV1234) who did this far before me, with roughly the same implementation, | |
| // a friend pointed this out after I finished implenting it (mine is slightly simpler though). | |
| #include <iostream> | |
| #include <type_traits> | |
| namespace details |
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
| // These implementations are ridiculous ... should have something more sensical, like gsl::string_span. | |
| // Only for testing purpose !! | |
| struct default_string_span | |
| { | |
| using iterator = std::string::const_iterator; | |
| default_string_span(iterator first, iterator last) | |
| : first(first), | |
| last(last){} |
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 <initializer_list> | |
| // The original version, by Eric Niebler and Sean Parent. Abusing brace initialization to make a liste expansion. | |
| // Would work with any variadic initializable construct, such as array types (T[]) | |
| template<class Fn, class ... Args> | |
| constexpr Fn for_each_args(Fn f, Args&& ... args) | |
| { | |
| using expander = std::initializer_list<int>; | |
| return ((void)expander{(f(args), 0)...}, f); |