-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update copyright year to 2024 and refactor type traits for consistency
- Loading branch information
Showing
26 changed files
with
220 additions
and
201 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,20 @@ | ||
// ArduinoJson - https://arduinojson.org | ||
// Copyright © 2014-2023, Benoit BLANCHON | ||
// Copyright © 2014-2024, Benoit BLANCHON | ||
// MIT License | ||
|
||
#pragma once | ||
|
||
template< bool Condition, class TrueType, class FalseType > | ||
struct conditional | ||
{ | ||
typedef TrueType type; | ||
struct conditional { | ||
using type = TrueType; | ||
}; | ||
|
||
template< class TrueType, class FalseType > | ||
struct conditional< false, TrueType, FalseType > | ||
{ | ||
typedef FalseType type; | ||
struct conditional<false, TrueType, FalseType> { | ||
using type = FalseType; | ||
}; | ||
|
||
template <bool Condition, class TrueType, class FalseType> | ||
using conditional_t = | ||
typename conditional<Condition, TrueType, FalseType>::type; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// ArduinoJson - https://arduinojson.org | ||
// Copyright © 2014-2024, Benoit BLANCHON | ||
// MIT License | ||
|
||
#pragma once | ||
|
||
#include <stddef.h> // size_t | ||
|
||
template <typename T> | ||
struct decay { | ||
using type = T; | ||
}; | ||
|
||
template <typename T> | ||
struct decay<T&> : decay<T> {}; | ||
|
||
template <typename T> | ||
struct decay<T&&> : decay<T> {}; | ||
|
||
template <typename T> | ||
struct decay<T[]> : decay<T*> {}; | ||
|
||
template <typename T, size_t N> | ||
struct decay<T[N]> : decay<T*> {}; | ||
|
||
template <typename T> | ||
using decay_t = typename decay<T>::type; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,17 @@ | ||
// ArduinoJson - https://arduinojson.org | ||
// Copyright © 2014-2023, Benoit BLANCHON | ||
// Copyright © 2014-2024, Benoit BLANCHON | ||
// MIT License | ||
|
||
#pragma once | ||
|
||
// A meta-function that return the type T if Condition is true. | ||
template< bool Condition, typename T = void > | ||
struct enable_if | ||
{ | ||
}; | ||
struct enable_if {}; | ||
|
||
template< typename T > | ||
struct enable_if< true, T > | ||
{ | ||
typedef T type; | ||
struct enable_if<true, T> { | ||
using type = T; | ||
}; | ||
|
||
template< bool B, class T = void > | ||
using enable_if_t = typename enable_if< B, T >::type; | ||
template <bool Condition, typename T = void > | ||
using enable_if_t = typename enable_if< Condition, T >::type; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// ArduinoJson - https://arduinojson.org | ||
// Copyright © 2014-2024, Benoit BLANCHON | ||
// MIT License | ||
|
||
#pragma once | ||
|
||
template <typename Sig> | ||
struct function_traits; | ||
|
||
template <typename ReturnType, typename Arg1> | ||
struct function_traits<ReturnType (*)(Arg1)> { | ||
using return_type = ReturnType; | ||
using arg1_type = Arg1; | ||
}; | ||
|
||
template <typename ReturnType, typename Arg1, typename Arg2> | ||
struct function_traits<ReturnType (*)(Arg1, Arg2)> { | ||
using return_type = ReturnType; | ||
using arg1_type = Arg1; | ||
using arg2_type = Arg2; | ||
}; | ||
|
25 changes: 9 additions & 16 deletions
25
Mk2_3phase_RFdatalog_temp/type_traits/integral_constant.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,17 @@ | ||
// ArduinoJson - https://arduinojson.org | ||
// Copyright © 2014-2023, Benoit BLANCHON | ||
// Copyright © 2014-2024, Benoit BLANCHON | ||
// MIT License | ||
|
||
#pragma once | ||
|
||
template< typename T, T v > | ||
struct integral_constant | ||
{ | ||
static constexpr T value = v; | ||
using value_type = T; | ||
using type = integral_constant; // using injected-class-name | ||
constexpr operator value_type() const noexcept | ||
{ | ||
return value; | ||
} | ||
constexpr value_type operator()() const noexcept | ||
{ | ||
return value; | ||
} // since c++14 | ||
struct integral_constant { | ||
static const T value = v; | ||
}; | ||
|
||
typedef integral_constant< bool, true > true_type; | ||
typedef integral_constant< bool, false > false_type; | ||
template <bool B> | ||
using bool_constant = integral_constant<bool, B>; | ||
|
||
using true_type = bool_constant<true>; | ||
using false_type = bool_constant<false>; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,16 @@ | ||
// ArduinoJson - https://arduinojson.org | ||
// Copyright © 2014-2023, Benoit BLANCHON | ||
// Copyright © 2014-2024, Benoit BLANCHON | ||
// MIT License | ||
|
||
#pragma once | ||
#include <stddef.h> | ||
|
||
// size_t | ||
template< typename T > | ||
struct is_array : false_type | ||
{ | ||
}; | ||
#include <stddef.h> // size_t | ||
|
||
template< typename T > | ||
struct is_array< T[] > : true_type | ||
{ | ||
}; | ||
template <typename T> | ||
struct is_array : false_type {}; | ||
|
||
template <typename T> | ||
struct is_array<T[]> : true_type {}; | ||
|
||
template< typename T, size_t N > | ||
struct is_array< T[N] > : true_type | ||
{ | ||
}; | ||
struct is_array<T[N]> : true_type {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,14 @@ | ||
// ArduinoJson - https://arduinojson.org | ||
// Copyright © 2014-2023, Benoit BLANCHON | ||
// Copyright © 2014-2024, Benoit BLANCHON | ||
// MIT License | ||
|
||
#pragma once | ||
|
||
#include "integral_constant.hpp" | ||
|
||
template< typename T > | ||
struct is_pointer : false_type | ||
{ | ||
}; | ||
struct is_pointer : false_type {}; | ||
|
||
template< typename T > | ||
struct is_pointer< T* > : true_type | ||
{ | ||
}; | ||
struct is_pointer<T*> : true_type {}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.