Skip to content

Commit 30f8c34

Browse files
Merge pull request #1703 from vsg-dev/ExtensibleBuilder
Convinience template function for cloning meta data.
2 parents 2594b01 + b362c82 commit 30f8c34

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

include/vsg/core/Object.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,4 +283,15 @@ namespace vsg
283283
return new_object.template cast<T>();
284284
}
285285

286+
/// clone a named meta data object stored within an object's Auxliary object if available, others default construct object
287+
template<class T, class C>
288+
ref_ptr<T> clone(const std::string& key, C container)
289+
{
290+
if (container)
291+
{
292+
if (auto prototype = container->template getRefObject<T>(key)) return vsg::clone(prototype);
293+
}
294+
return T::create();
295+
}
296+
286297
} // namespace vsg

0 commit comments

Comments
 (0)