diff options
Diffstat (limited to 'include/ble/compiler-support.h')
-rw-r--r-- | include/ble/compiler-support.h | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/include/ble/compiler-support.h b/include/ble/compiler-support.h new file mode 100644 index 0000000..1e7e185 --- /dev/null +++ b/include/ble/compiler-support.h @@ -0,0 +1,62 @@ +#ifndef COMPILER_SUPPORT_H + +#ifdef __has_include + +# if __has_include(<optional>) +# include <optional> +# define have_optional 1 +# elif __has_include(<experimental/optional>) +# include <experimental/optional> +# define have_optional 1 +# define have_experimental_optional 1 +# else +# define have_optional 0 +# endif + +# if __has_include(<variant>) +# include <variant> +# define have_variant 1 +# elif __has_include(<experimental/variant>) +# include <experimental/variant> +# define have_variant 1 +# define have_experimental_variant 1 +# else +# define have_variant 0 +# endif + +#endif + +namespace trygvis { +namespace compiler { + +#if have_experimental_optional + +template<typename T> +using o = std::experimental::optional<T>; + +#elif have_optional + +template<typename T> +using o = std::optional<T>; + +#endif + +#if have_experimental_variant + +template<typename... T> +using variant = std::experimental::variant<T>; +using monostate = std::experimental::monostate; + +#elif have_variant + +template<typename... T> +using variant = std::variant<T...>; +using monostate = std::monostate; + +#endif + +} // namespace compiler +} // namespace trygvis + + +#endif |