MapLibre Native Core
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
traits.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <array>
4 #include <cstdint>
5 #include <type_traits>
6 #include <vector>
7 
8 namespace mbgl {
9 
10 template<typename T>
11 constexpr auto underlying_type(T t) -> typename std::underlying_type_t<T> {
12  return typename std::underlying_type_t<T>(t);
13 }
14 
15 template <typename T> struct is_utf16char_like: std::false_type {};
16 template <typename T> struct is_utf16char_like<const T>: is_utf16char_like<T> {};
17 template <> struct is_utf16char_like<char16_t>: std::true_type {};
18 template <> struct is_utf16char_like<wchar_t>: std::true_type {};
19 template <> struct is_utf16char_like<uint16_t>: std::true_type {};
20 
21 template <typename T> using is_utf16char_like_pointer = std::integral_constant<bool, std::is_pointer_v<T>
23 
24 template <class OutPointer, class InChar>
25 typename std::enable_if<is_utf16char_like<InChar>::value && is_utf16char_like_pointer<OutPointer>::value, OutPointer>::type utf16char_cast(InChar *in)
26 {
27  return reinterpret_cast<OutPointer>(in);
28 }
29 
30 template <typename T>
31 struct is_linear_container : std::false_type {};
32 
33 template <typename T, std::size_t N>
34 struct is_linear_container<std::array<T, N>> : std::true_type {};
35 template <typename... Ts>
36 struct is_linear_container<std::vector<Ts...>> : std::true_type {};
37 
38 } // namespace mbgl
Definition: actor.hpp:15
std::enable_if< is_utf16char_like< InChar >::value &&is_utf16char_like_pointer< OutPointer >::value, OutPointer >::type utf16char_cast(InChar *in)
Definition: traits.hpp:25
std::integral_constant< bool, std::is_pointer_v< T > &&is_utf16char_like< typename std::remove_pointer< T >::type >::value > is_utf16char_like_pointer
Definition: traits.hpp:22
constexpr auto underlying_type(T t) -> typename std::underlying_type_t< T >
Definition: traits.hpp:11
Definition: tile_id.hpp:256