-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
130 additions
and
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -117,6 +117,7 @@ | |
"cSpell.words": [ | ||
"cmake", | ||
"codecov", | ||
"declval", | ||
"GCOVR", | ||
"jwlawson", | ||
"pnpm" | ||
|
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
26 changes: 26 additions & 0 deletions
26
include/snapshot/types_check/has_class_internal_to_string.h
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,26 @@ | ||
#ifndef SNAPSHOT_INTERNAL_TYPES_CHECK_HAS_CLASS_INTERNAL_TO_STRING_H_ | ||
#define SNAPSHOT_INTERNAL_TYPES_CHECK_HAS_CLASS_INTERNAL_TO_STRING_H_ | ||
|
||
#include <type_traits> | ||
|
||
namespace snapshot::internal { | ||
|
||
template <typename T> | ||
class has_class_internal_to_string { | ||
private: | ||
template <typename U> | ||
static auto check(int) -> decltype(std::declval<U>().ToString(), std::true_type()); | ||
|
||
template <typename U> | ||
static std::false_type check(...); | ||
|
||
public: | ||
enum { value = std::is_same<decltype(check<T>(0)), std::true_type>::value }; | ||
}; | ||
|
||
template <typename T> | ||
inline constexpr bool has_class_internal_to_string_v = has_class_internal_to_string<T>::value; | ||
|
||
} // namespace snapshot::internal | ||
|
||
#endif // SNAPSHOT_INTERNAL_TYPES_CHECK_HAS_CLASS_INTERNAL_TO_STRING_H_ |
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,26 @@ | ||
#ifndef SNAPSHOT_INTERNAL_TYPES_CHECK_HAS_GLOBAL_TO_STRING_H_ | ||
#define SNAPSHOT_INTERNAL_TYPES_CHECK_HAS_GLOBAL_TO_STRING_H_ | ||
|
||
#include <type_traits> | ||
|
||
namespace snapshot::internal { | ||
|
||
template <typename T> | ||
class has_global_to_string { | ||
private: | ||
template <typename U> | ||
static auto check(int) -> decltype(to_string(std::declval<U>()), std::true_type()); | ||
|
||
template <typename U> | ||
static std::false_type check(...); | ||
|
||
public: | ||
enum { value = std::is_same<decltype(check<T>(0)), std::true_type>::value }; | ||
}; | ||
|
||
template <typename T> | ||
inline constexpr bool has_global_to_string_v = has_global_to_string<T>::value; | ||
|
||
} // namespace snapshot::internal | ||
|
||
#endif // SNAPSHOT_INTERNAL_TYPES_CHECK_HAS_GLOBAL_TO_STRING_H_ |
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 @@ | ||
#ifndef SNAPSHOT_INTERNAL_TYPES_CHECK_HAS_OPERATOR_STREAM_H_ | ||
#define SNAPSHOT_INTERNAL_TYPES_CHECK_HAS_OPERATOR_STREAM_H_ | ||
|
||
#include <iostream> | ||
#include <utility> | ||
|
||
namespace snapshot::internal { | ||
|
||
template <typename T> | ||
class has_operator_stream { | ||
private: | ||
template <typename U> | ||
static auto check(int) -> decltype(operator<<(std::cout, std::declval<U>()), std::true_type()); | ||
|
||
template <typename U> | ||
static std::false_type check(...); | ||
|
||
public: | ||
enum { value = std::is_same<decltype(check<T>(0)), std::true_type>::value }; | ||
}; | ||
|
||
template <typename T> | ||
inline constexpr bool has_operator_stream_v = has_operator_stream<T>::value; | ||
|
||
} // namespace snapshot::internal | ||
|
||
#endif // SNAPSHOT_INTERNAL_TYPES_CHECK_HAS_OPERATOR_STREAM_H_ |
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 @@ | ||
#ifndef SNAPSHOT_TYPES_CHECK_HAS_STD_TO_STRING_H | ||
#define SNAPSHOT_TYPES_CHECK_HAS_STD_TO_STRING_H | ||
|
||
#include <string> | ||
#include <type_traits> | ||
|
||
namespace snapshot::internal { | ||
|
||
template <typename T> | ||
class has_std_to_string { | ||
private: | ||
template <typename U> | ||
static auto check(int) -> decltype(std::to_string(std::declval<U>()), std::true_type()); | ||
|
||
template <typename U> | ||
static std::false_type check(...); | ||
|
||
public: | ||
enum { value = std::is_same<decltype(check<T>(0)), std::true_type>::value }; | ||
}; | ||
|
||
template <typename T> | ||
inline constexpr bool has_std_to_string_v = has_std_to_string<T>::value; | ||
|
||
} // namespace snapshot::internal | ||
|
||
#endif // SNAPSHOT_TYPES_CHECK_HAS_STD_TO_STRING_H |
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