From a2daf92a57e45039fe928a9bc6251e8f8fc2bd6d Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Tue, 12 Oct 2021 16:40:02 +0200 Subject: Fix warning about deleted default constructor declared as default MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since `AssetCatalogPath` isn't default constructible (unlike the previous `CatalogPath`, alias `std::string`), `AssetCatalog` isn't default constructible either. But its default constructor is declared with `= default` which Apple Clang was warning about. Differential Revision: https://developer.blender.org/D12714 Reviewed by: Sybren Stüvel --- source/blender/blenkernel/BKE_asset_catalog_path.hh | 4 ++-- source/blender/blenkernel/intern/asset_catalog_path_test.cc | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/BKE_asset_catalog_path.hh b/source/blender/blenkernel/BKE_asset_catalog_path.hh index 054b7853140..f51232334f2 100644 --- a/source/blender/blenkernel/BKE_asset_catalog_path.hh +++ b/source/blender/blenkernel/BKE_asset_catalog_path.hh @@ -56,12 +56,12 @@ class AssetCatalogPath { /** * The path itself, such as "Agents/Secret/327". */ - std::string path_; + std::string path_ = ""; public: static const char SEPARATOR; - AssetCatalogPath() = delete; + AssetCatalogPath() = default; AssetCatalogPath(StringRef path); AssetCatalogPath(const std::string &path); AssetCatalogPath(const char *path); diff --git a/source/blender/blenkernel/intern/asset_catalog_path_test.cc b/source/blender/blenkernel/intern/asset_catalog_path_test.cc index d8da91d5d18..be50f2fc001 100644 --- a/source/blender/blenkernel/intern/asset_catalog_path_test.cc +++ b/source/blender/blenkernel/intern/asset_catalog_path_test.cc @@ -31,6 +31,16 @@ namespace blender::bke::tests { TEST(AssetCatalogPathTest, construction) { + AssetCatalogPath default_constructed; + /* Use `.str()` to use `std:string`'s comparison operators here, not our own (which are tested + * later). */ + EXPECT_EQ(default_constructed.str(), ""); + + /* C++ considers this construction special, it doesn't call the default constructor but does + * recursive, member-wise value initialization. See https://stackoverflow.com/a/4982720. */ + AssetCatalogPath value_initialized = AssetCatalogPath(); + EXPECT_EQ(value_initialized.str(), ""); + AssetCatalogPath from_char_literal("the/path"); const std::string str_const = "the/path"; -- cgit v1.2.3