summaryrefslogtreecommitdiff
path: root/include/lib/ArduinoJson/Polyfills/alias_cast.hpp
blob: 96fa4a1b673f28214e0a658678404dde32692cd2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021
// MIT License

#pragma once

#include <stdint.h>
#include <stdlib.h>  // for size_t

#include "lib/ArduinoJson/Configuration.hpp"
#include "math.hpp"

namespace ARDUINOJSON_NAMESPACE {

template <typename T, typename F>
struct alias_cast_t {
  union {
    F raw;
    T data;
  };
};

template <typename T, typename F>
T alias_cast(F raw_data) {
  alias_cast_t<T, F> ac;
  ac.raw = raw_data;
  return ac.data;
}
}  // namespace ARDUINOJSON_NAMESPACE