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
This commit is contained in:
Julian Eisel 2021-10-12 16:40:02 +02:00
parent 1db42c9b79
commit a2daf92a57
2 changed files with 12 additions and 2 deletions

View File

@ -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);

View File

@ -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";