summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2022-11-16 15:26:53 +0100
committerStanislaw Halik <sthalik@misaki.pl>2022-11-16 15:26:53 +0100
commit1dd83437e5777f699184452667e7698072fd5cb4 (patch)
treecf54213c03b63feabdaaedbf6eb00e8e4cb2ec81
parentc82c854297d216bbc1901ffa9dd18f87a1d514e4 (diff)
entity: pass small trivial types by value
-rw-r--r--src/entity.hpp3
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&>;