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> | |
template <typename T, typename U> | |
constexpr inline T &force_cast(U &u) { return (*reinterpret_cast<T *>(&u)); } | |
template <typename T, typename U> | |
constexpr inline const T &force_cast(const U &u) { return (*reinterpret_cast<const T *>(&u)); } | |
struct foo { int value = 123; }; |
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> | |
// impl ---------- | |
#if (__cplusplus > 201402L) | |
using std::bool_constant; | |
using std::negation; | |
using std::conjunction; | |
using std::disjunction; |
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 <sstream> | |
#ifdef __GNUG__ | |
#include <cstdlib> | |
#include <memory> | |
#include <cxxabi.h> | |
std::string demangle(const char *name) { |
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> | |
// impl ---------- | |
template <typename T> | |
struct accessor { | |
static typename T::type value; | |
}; | |
template <typename 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
#include <type_traits> | |
#include <iostream> | |
template <typename T, typename = typename std::is_enum<T>::type> | |
struct safe_underlying_type { using type = T; }; | |
template <typename T> | |
struct safe_underlying_type<T, std::true_type> { using type = std::underlying_type_t<T>; }; | |
template <typename 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
#include <iostream> | |
#include <type_traits> | |
template <typename T, typename = typename std::is_enum<T>::type> | |
struct safe_underlying_type { using type = T; }; | |
template <typename T> | |
struct safe_underlying_type<T, std::true_type> { using type = std::underlying_type_t<T>; }; | |
template <typename 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
#include <type_traits> | |
// impl ---------- | |
#if (__cplusplus > 201402L) | |
using std::void_t; | |
#else |
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 <type_traits> | |
#if (__cplusplus > 201402L) | |
using std::void_t; | |
using std::bool_constant; | |
using std::negation; | |
using std::conjunction; | |
using std::conjunction_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
#include <iostream> | |
#include <type_traits> | |
struct has_value_impl { | |
template <class T, class U = decltype(T::value)> | |
constexpr static std::is_same<U, int> test_variable(int); | |
template <typename...> | |
constexpr static std::false_type test_variable(...); | |
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 <sstream> | |
#include <string> | |
#include <locale> | |
#include <codecvt> | |
using w32stringstream = std::basic_stringstream<char32_t>; | |
int main() | |
{ |