blob: 9ce7b3acc35221232a5d51dd779a5626c13faeab [file] [log] [blame]
Doug Horn1427b6a2018-12-11 13:19:16 -08001// 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
12namespace fidl {
13
14// A type trait that indiciates whether the given type is a primitive FIDL
15// type.
16template <typename T>
17struct IsPrimitive : public std::false_type {};
18
19// clang-format off
20template <> struct IsPrimitive<bool> : public std::true_type {};
21template <> struct IsPrimitive<uint8_t> : public std::true_type {};
22template <> struct IsPrimitive<uint16_t> : public std::true_type {};
23template <> struct IsPrimitive<uint32_t> : public std::true_type {};
24template <> struct IsPrimitive<uint64_t> : public std::true_type {};
25template <> struct IsPrimitive<int8_t> : public std::true_type {};
26template <> struct IsPrimitive<int16_t> : public std::true_type {};
27template <> struct IsPrimitive<int32_t> : public std::true_type {};
28template <> struct IsPrimitive<int64_t> : public std::true_type {};
29template <> struct IsPrimitive<float> : public std::true_type {};
30template <> struct IsPrimitive<double> : public std::true_type {};
31// clang-format on
32
33} // namespace fidl
34
35#endif // LIB_FIDL_CPP_TRAITS_H_