[Bf-blender-cvs] [0491ba09c21] master: Cleanup: Remove data duplication from BLI_any.hh support variables
Jesse Yurkovich
noreply at git.blender.org
Fri Aug 19 04:42:37 CEST 2022
Commit: 0491ba09c21a89f3ac32cb93a7800c95aacb0816
Author: Jesse Yurkovich
Date: Thu Aug 18 19:40:15 2022 -0700
Branches: master
https://developer.blender.org/rB0491ba09c21a89f3ac32cb93a7800c95aacb0816
Cleanup: Remove data duplication from BLI_any.hh support variables
Use `inline constexpr` instead of `static constexpr` to prevent these
variables from being duplicated in each translation unit that includes
the BLI_any.hh header.
Differential Revision: https://developer.blender.org/D15698
===================================================================
M source/blender/blenlib/BLI_any.hh
===================================================================
diff --git a/source/blender/blenlib/BLI_any.hh b/source/blender/blenlib/BLI_any.hh
index a20239f214f..f9b53436763 100644
--- a/source/blender/blenlib/BLI_any.hh
+++ b/source/blender/blenlib/BLI_any.hh
@@ -39,7 +39,7 @@ template<typename ExtraInfo> struct AnyTypeInfo {
* Used when #T is stored directly in the inline buffer of the #Any.
*/
template<typename ExtraInfo, typename T>
-static constexpr AnyTypeInfo<ExtraInfo> info_for_inline = {
+inline constexpr AnyTypeInfo<ExtraInfo> info_for_inline = {
is_trivially_copy_constructible_extended_v<T> ?
nullptr :
+[](void *dst, const void *src) { new (dst) T(*(const T *)src); },
@@ -57,7 +57,7 @@ static constexpr AnyTypeInfo<ExtraInfo> info_for_inline = {
*/
template<typename T> using Ptr = std::unique_ptr<T>;
template<typename ExtraInfo, typename T>
-static constexpr AnyTypeInfo<ExtraInfo> info_for_unique_ptr = {
+inline constexpr AnyTypeInfo<ExtraInfo> info_for_unique_ptr = {
[](void *dst, const void *src) { new (dst) Ptr<T>(new T(**(const Ptr<T> *)src)); },
[](void *dst, void *src) { new (dst) Ptr<T>(new T(std::move(**(Ptr<T> *)src))); },
[](void *src) { std::destroy_at((Ptr<T> *)src); },
More information about the Bf-blender-cvs
mailing list