Doug Horn | 1427b6a | 2018-12-11 13:19:16 -0800 | [diff] [blame] | 1 | // Copyright 2018 The Fuchsia Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef LIB_FIDL_CPP_TRAITS_H_ |
| 6 | #define LIB_FIDL_CPP_TRAITS_H_ |
| 7 | |
| 8 | #include <stdint.h> |
| 9 | |
| 10 | #include <type_traits> |
| 11 | |
| 12 | namespace fidl { |
| 13 | |
| 14 | // A type trait that indiciates whether the given type is a primitive FIDL |
| 15 | // type. |
| 16 | template <typename T> |
| 17 | struct IsPrimitive : public std::false_type {}; |
| 18 | |
| 19 | // clang-format off |
| 20 | template <> struct IsPrimitive<bool> : public std::true_type {}; |
| 21 | template <> struct IsPrimitive<uint8_t> : public std::true_type {}; |
| 22 | template <> struct IsPrimitive<uint16_t> : public std::true_type {}; |
| 23 | template <> struct IsPrimitive<uint32_t> : public std::true_type {}; |
| 24 | template <> struct IsPrimitive<uint64_t> : public std::true_type {}; |
| 25 | template <> struct IsPrimitive<int8_t> : public std::true_type {}; |
| 26 | template <> struct IsPrimitive<int16_t> : public std::true_type {}; |
| 27 | template <> struct IsPrimitive<int32_t> : public std::true_type {}; |
| 28 | template <> struct IsPrimitive<int64_t> : public std::true_type {}; |
| 29 | template <> struct IsPrimitive<float> : public std::true_type {}; |
| 30 | template <> struct IsPrimitive<double> : public std::true_type {}; |
| 31 | // clang-format on |
| 32 | |
| 33 | } // namespace fidl |
| 34 | |
| 35 | #endif // LIB_FIDL_CPP_TRAITS_H_ |