diff options
| author | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-08-21 21:43:33 +0100 | 
|---|---|---|
| committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-08-21 21:43:33 +0100 | 
| commit | ca9a42002d4d7ac82cc48f8afd3748df5db7ccd4 (patch) | |
| tree | 68b84128ef988adbcc4e2a652dbdfa8041881256 | |
| parent | Add a DB perf case for a complex with non-optional members (diff) | |
| download | slicer-ca9a42002d4d7ac82cc48f8afd3748df5db7ccd4.tar.bz2 slicer-ca9a42002d4d7ac82cc48f8afd3748df5db7ccd4.tar.xz slicer-ca9a42002d4d7ac82cc48f8afd3748df5db7ccd4.zip  | |
Create Optional ModelParts on the stack with std::optional
Supercedes the previous change to unique_ptr and now all ModelParts are on the stack.
| -rw-r--r-- | slicer/slicer/modelParts.h | 1 | ||||
| -rw-r--r-- | slicer/slicer/modelPartsTypes.h | 3 | ||||
| -rw-r--r-- | slicer/slicer/modelPartsTypes.impl.h | 4 | 
3 files changed, 4 insertions, 4 deletions
diff --git a/slicer/slicer/modelParts.h b/slicer/slicer/modelParts.h index de6e89f..8adc8f2 100644 --- a/slicer/slicer/modelParts.h +++ b/slicer/slicer/modelParts.h @@ -78,7 +78,6 @@ namespace Slicer {  	class ModelPartForRootBase;  	class HookCommon; -	using ModelPartUPtr = std::unique_ptr<ModelPart>;  	using ModelPartParam = any_ptr<ModelPart>;  	using ModelPartForRootParam = any_ptr<ModelPartForRootBase>;  	using TypeId = std::optional<std::string>; diff --git a/slicer/slicer/modelPartsTypes.h b/slicer/slicer/modelPartsTypes.h index f8a8814..2079195 100644 --- a/slicer/slicer/modelPartsTypes.h +++ b/slicer/slicer/modelPartsTypes.h @@ -113,7 +113,7 @@ namespace Slicer {  	protected:  		virtual bool hasModel() const = 0; -		ModelPartUPtr modelPart; +		ModelPart * modelPart;  	};  	template<typename T> @@ -129,6 +129,7 @@ namespace Slicer {  	protected:  		bool hasModel() const override; +		std::optional<T> modelPartOwner;  	};  	class DLL_PUBLIC ModelPartForComplexBase : public ModelPart { diff --git a/slicer/slicer/modelPartsTypes.impl.h b/slicer/slicer/modelPartsTypes.impl.h index dc6ff07..ad1a90f 100644 --- a/slicer/slicer/modelPartsTypes.impl.h +++ b/slicer/slicer/modelPartsTypes.impl.h @@ -306,7 +306,7 @@ namespace Slicer {  		ModelPartModel<Ice::optional<typename T::element_type>>(h)  	{  		if (this->Model && *this->Model) { -			modelPart = std::make_unique<T>(&**this->Model); +			modelPart = &modelPartOwner.emplace(&**this->Model);  		}  	} @@ -325,7 +325,7 @@ namespace Slicer {  		BOOST_ASSERT(this->Model);  		if (!*this->Model) {  			*this->Model = typename T::element_type(); -			modelPart = std::make_unique<T>(&**this->Model); +			modelPart = &modelPartOwner.emplace(&**this->Model);  			modelPart->Create();  		}  	}  | 
