diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2022-11-16 15:26:53 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-11-16 15:26:53 +0100 |
commit | 1dd83437e5777f699184452667e7698072fd5cb4 (patch) | |
tree | cf54213c03b63feabdaaedbf6eb00e8e4cb2ec81 /src | |
parent | c82c854297d216bbc1901ffa9dd18f87a1d514e4 (diff) |
entity: pass small trivial types by value
Diffstat (limited to 'src')
-rw-r--r-- | src/entity.hpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/entity.hpp b/src/entity.hpp index 10df2366..8d62780b 100644 --- a/src/entity.hpp +++ b/src/entity.hpp @@ -12,8 +12,9 @@ namespace floormat {} namespace floormat::entities { -template<typename T> struct pass_by_value : std::bool_constant<std::is_fundamental_v<T>> {}; +template<typename T, typename = void> struct pass_by_value : std::bool_constant<std::is_fundamental_v<T>> {}; template<> struct pass_by_value<StringView> : std::true_type {}; +template<typename T> struct pass_by_value<T, std::enable_if_t<std::is_trivially_copy_constructible_v<T> && sizeof(T) <= sizeof(void*)>> : std::true_type {}; template<typename T> constexpr inline bool pass_by_value_v = pass_by_value<T>::value; template<typename T> using const_qualified = std::conditional_t<pass_by_value_v<T>, T, const T&>; |