[Bf-blender-cvs] [a2daf92a57e] master: Fix warning about deleted default constructor declared as default
Julian Eisel
noreply at git.blender.org
Tue Oct 12 16:41:00 CEST 2021
Commit: a2daf92a57e45039fe928a9bc6251e8f8fc2bd6d
Author: Julian Eisel
Date: Tue Oct 12 16:40:02 2021 +0200
Branches: master
https://developer.blender.org/rBa2daf92a57e45039fe928a9bc6251e8f8fc2bd6d
Fix warning about deleted default constructor declared as default
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
===================================================================
M source/blender/blenkernel/BKE_asset_catalog_path.hh
M source/blender/blenkernel/intern/asset_catalog_path_test.cc
===================================================================
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";
More information about the Bf-blender-cvs
mailing list