diff --git a/pxr/usd/pcp/composeSite.cpp b/pxr/usd/pcp/composeSite.cpp index 0ac1e53a03..72b6a0aa29 100644 --- a/pxr/usd/pcp/composeSite.cpp +++ b/pxr/usd/pcp/composeSite.cpp @@ -105,7 +105,7 @@ _PcpComposeSiteReferencesOrPayloads( // relative to the layer where they were expressed. curListOp.ApplyOperations(result, [&](SdfListOpType opType, const RefOrPayloadType& refOrPayload) - -> boost::optional + -> std::optional { // Fill in the result reference or payload with the anchored // asset path instead of the authored asset path. This @@ -126,7 +126,7 @@ _PcpComposeSiteReferencesOrPayloads( // layer. If the empty result was due to an error, that // will have already been saved to the errors list above. if (authoredAssetPath.empty()) { - return boost::none; + return std::nullopt; } assetPath = SdfComputeAssetPathRelativeToLayer( diff --git a/pxr/usd/pcp/targetIndex.cpp b/pxr/usd/pcp/targetIndex.cpp index 9094ba29a8..9520ba5c8b 100644 --- a/pxr/usd/pcp/targetIndex.cpp +++ b/pxr/usd/pcp/targetIndex.cpp @@ -37,9 +37,8 @@ #include "pxr/base/trace/trace.h" -#include - #include +#include PXR_NAMESPACE_OPEN_SCOPE @@ -319,7 +318,7 @@ _RemoveTargetPathErrorsForPath( // Callback used to translate paths as path list operations from // various nodes are applied. -static boost::optional +static std::optional _PathTranslateCallback( SdfListOpType opType, const PcpSite &propSite, @@ -352,7 +351,7 @@ _PathTranslateCallback( _RemoveTargetPathErrorsForPath(translatedPath, targetPathErrors); return translatedPath; } - return boost::optional(); + return std::optional(); } if (!pathIsMappable) { @@ -367,11 +366,11 @@ _PathTranslateCallback( err->layer = owningProp->GetLayer(); err->composedTargetPath = SdfPath(); targetPathErrors->push_back(err); - return boost::optional(); + return std::optional(); } if (translatedPath.IsEmpty()) { - return boost::optional(); + return std::optional(); } if (cacheForValidation) { @@ -390,7 +389,7 @@ _PathTranslateCallback( err->layer = owningProp->GetLayer(); err->composedTargetPath = translatedPath; targetPathErrors->push_back(err); - return boost::optional(); + return std::optional(); } // Check if the connection is invalid due to permissions or @@ -410,7 +409,7 @@ _PathTranslateCallback( err->layer = owningProp->GetLayer(); err->composedTargetPath = translatedPath; targetPathErrors->push_back(err); - return boost::optional(); + return std::optional(); } case InvalidTarget: @@ -424,7 +423,7 @@ _PathTranslateCallback( err->layer = owningProp->GetLayer(); err->composedTargetPath = translatedPath; targetPathErrors->push_back(err); - return boost::optional(); + return std::optional(); } case NoError: diff --git a/pxr/usd/sdf/layer.cpp b/pxr/usd/sdf/layer.cpp index 7166b690c2..265850881e 100644 --- a/pxr/usd/sdf/layer.cpp +++ b/pxr/usd/sdf/layer.cpp @@ -76,6 +76,7 @@ #include #include #include +#include #include #include #include @@ -3204,7 +3205,7 @@ SdfLayer::GetExternalAssetDependencies() const // ModifyItemEdits() callback that updates a reference's or payload's // asset path for SdfReferenceListEditor and SdfPayloadListEditor. template -static boost::optional +static std::optional _UpdateRefOrPayloadPath( const string &oldLayerPath, const string &newLayerPath, @@ -3213,7 +3214,7 @@ _UpdateRefOrPayloadPath( if (refOrPayload.GetAssetPath() == oldLayerPath) { // Delete if new layer path is empty, otherwise rename. if (newLayerPath.empty()) { - return boost::optional(); + return std::optional(); } else { RefOrPayloadType updatedRefOrPayload = refOrPayload; updatedRefOrPayload.SetAssetPath(newLayerPath); diff --git a/pxr/usd/sdf/listEditor.h b/pxr/usd/sdf/listEditor.h index fbff3929a8..f7a636e625 100644 --- a/pxr/usd/sdf/listEditor.h +++ b/pxr/usd/sdf/listEditor.h @@ -33,9 +33,8 @@ #include "pxr/usd/sdf/schema.h" #include "pxr/usd/sdf/spec.h" -#include - #include +#include PXR_NAMESPACE_OPEN_SCOPE @@ -119,7 +118,7 @@ class Sdf_ListEditor virtual bool ClearEditsAndMakeExplicit() = 0; typedef std::function< - boost::optional(const value_type&) + std::optional(const value_type&) > ModifyCallback; @@ -132,7 +131,7 @@ class Sdf_ListEditor virtual void ModifyItemEdits(const ModifyCallback& cb) = 0; typedef std::function< - boost::optional(SdfListOpType, const value_type&) + std::optional(SdfListOpType, const value_type&) > ApplyCallback; diff --git a/pxr/usd/sdf/listEditorProxy.h b/pxr/usd/sdf/listEditorProxy.h index 4741c2adaa..5f0f223349 100644 --- a/pxr/usd/sdf/listEditorProxy.h +++ b/pxr/usd/sdf/listEditorProxy.h @@ -33,10 +33,9 @@ #include "pxr/base/vt/value.h" // for Vt_DefaultValueFactory -#include - #include #include +#include PXR_NAMESPACE_OPEN_SCOPE @@ -63,11 +62,11 @@ class SdfListEditorProxy { typedef std::vector value_vector_type; // ApplyEdits types. - typedef std::function + typedef std::function (SdfListOpType, const value_type&)> ApplyCallback; // ModifyEdits types. - typedef std::function + typedef std::function (const value_type&)> ModifyCallback; /// Creates a default proxy object. The object evaluates to \c false in a diff --git a/pxr/usd/sdf/listOp.cpp b/pxr/usd/sdf/listOp.cpp index c227be5153..9a2d4b9472 100644 --- a/pxr/usd/sdf/listOp.cpp +++ b/pxr/usd/sdf/listOp.cpp @@ -36,8 +36,6 @@ #include "pxr/base/tf/token.h" #include "pxr/base/trace/trace.h" -#include - #include using std::string; @@ -344,7 +342,7 @@ SdfListOp::ApplyOperations(ItemVector* vec, const ApplyCallback& cb) const } template -boost::optional> +std::optional> SdfListOp::ApplyOperations(const SdfListOp &inner) const { if (IsExplicit()) { @@ -422,7 +420,7 @@ SdfListOp::ApplyOperations(const SdfListOp &inner) const // and there is no way to express the relative order dependency // between 0 and 1. // - return boost::optional>(); + return std::optional>(); } template @@ -468,7 +466,7 @@ SdfListOp::_AddKeys( { TF_FOR_ALL(i, GetItems(op)) { if (callback) { - if (boost::optional item = callback(op, *i)) { + if (std::optional item = callback(op, *i)) { // Only append if the item isn't already present. _InsertIfUnique(*item, result, search); } @@ -490,7 +488,7 @@ SdfListOp::_PrependKeys( const ItemVector& items = GetItems(op); if (callback) { for (auto i = items.rbegin(), iEnd = items.rend(); i != iEnd; ++i) { - if (boost::optional mappedItem = callback(op, *i)) { + if (std::optional mappedItem = callback(op, *i)) { _InsertOrMove(*mappedItem, result->begin(), result, search); } } @@ -512,7 +510,7 @@ SdfListOp::_AppendKeys( const ItemVector& items = GetItems(op); if (callback) { for (const T& item: items) { - if (boost::optional mappedItem = callback(op, item)) { + if (std::optional mappedItem = callback(op, item)) { _InsertOrMove(*mappedItem, result->end(), result, search); } } @@ -533,7 +531,7 @@ SdfListOp::_DeleteKeys( { TF_FOR_ALL(i, GetItems(op)) { if (callback) { - if (boost::optional item = callback(op, *i)) { + if (std::optional item = callback(op, *i)) { _RemoveIfPresent(*item, result, search); } } @@ -556,7 +554,7 @@ SdfListOp::_ReorderKeys( std::set orderSet; TF_FOR_ALL(i, GetItems(op)) { if (callback) { - if (boost::optional item = callback(op, *i)) { + if (std::optional item = callback(op, *i)) { if (orderSet.insert(*item).second) { order.push_back(*item); } @@ -612,10 +610,10 @@ _ModifyCallbackHelper(const typename SdfListOp::ModifyCallback& cb, TfDenseHashSet existingSet; for (const T& item : *itemVector) { - boost::optional modifiedItem = cb(item); + std::optional modifiedItem = cb(item); if (removeDuplicates && modifiedItem) { if (!existingSet.insert(*modifiedItem).second) { - modifiedItem = boost::none; + modifiedItem = std::nullopt; } } diff --git a/pxr/usd/sdf/listOp.h b/pxr/usd/sdf/listOp.h index d443d22e27..01824396d0 100644 --- a/pxr/usd/sdf/listOp.h +++ b/pxr/usd/sdf/listOp.h @@ -29,12 +29,11 @@ #include "pxr/base/tf/token.h" #include "pxr/base/tf/hash.h" -#include - #include #include #include #include +#include #include #include @@ -188,7 +187,7 @@ class SdfListOp { /// Callback type for ApplyOperations. typedef std::function< - boost::optional(SdfListOpType, const ItemType&) + std::optional(SdfListOpType, const ItemType&) > ApplyCallback; /// Applies edit operations to the given ItemVector. @@ -211,12 +210,12 @@ class SdfListOp { /// the explicit, prepended, appended, and deleted portions of /// SdfListOp are closed under composition with ApplyOperations(). SDF_API - boost::optional> + std::optional> ApplyOperations(const SdfListOp &inner) const; /// Callback type for ModifyOperations. typedef std::function< - boost::optional(const ItemType&) + std::optional(const ItemType&) > ModifyCallback; /// Modifies operations specified in this object. diff --git a/pxr/usd/sdf/listOpListEditor.h b/pxr/usd/sdf/listOpListEditor.h index debe871961..218d675d18 100644 --- a/pxr/usd/sdf/listOpListEditor.h +++ b/pxr/usd/sdf/listOpListEditor.h @@ -91,12 +91,12 @@ class Sdf_ListOpListEditor private: static - boost::optional + std::optional _ModifyCallbackHelper(const ModifyCallback& cb, const TypePolicy& typePolicy, const value_type& v) { - boost::optional value = cb(v); + std::optional value = cb(v); return value ? typePolicy.Canonicalize(*value) : value; } diff --git a/pxr/usd/sdf/listProxy.h b/pxr/usd/sdf/listProxy.h index df58d850b0..913617bbe8 100644 --- a/pxr/usd/sdf/listProxy.h +++ b/pxr/usd/sdf/listProxy.h @@ -35,9 +35,9 @@ #include "pxr/base/tf/diagnostic.h" #include "pxr/base/tf/errorMark.h" #include "pxr/base/tf/iterator.h" -#include #include +#include #include PXR_NAMESPACE_OPEN_SCOPE @@ -663,10 +663,10 @@ class SdfListProxy { /// Modify all edits in this list. /// /// \p callback must be a callable that accepts an argument of type - /// value_type and returns a boost::optional. + /// value_type and returns a std::optional. /// /// \p callback is called with every item in the list. If an invalid - /// boost::optional is returned, the item is removed. Otherwise it's + /// std::optional is returned, the item is removed. Otherwise it's /// replaced with the returned item. If a returned item matches an /// item that was previously returned, the returned item will be /// removed. diff --git a/pxr/usd/sdf/pyListEditorProxy.h b/pxr/usd/sdf/pyListEditorProxy.h index 8ada0a47e1..738eacc7b8 100644 --- a/pxr/usd/sdf/pyListEditorProxy.h +++ b/pxr/usd/sdf/pyListEditorProxy.h @@ -54,7 +54,7 @@ class Sdf_PyListEditorUtils { // Do nothing } - boost::optional operator()(SdfListOpType op, const V& value) + std::optional operator()(SdfListOpType op, const V& value) { using namespace boost::python; @@ -63,14 +63,14 @@ class Sdf_PyListEditorUtils { if (! TfPyIsNone(result)) { extract e(result); if (e.check()) { - return boost::optional(e()); + return std::optional(e()); } else { TF_CODING_ERROR("ApplyEditsToList callback has " "incorrect return type."); } } - return boost::optional(); + return std::optional(); } private: @@ -87,7 +87,7 @@ class Sdf_PyListEditorUtils { // Do nothing } - boost::optional operator()(const V& value) + std::optional operator()(const V& value) { using namespace boost::python; @@ -96,14 +96,14 @@ class Sdf_PyListEditorUtils { if (! TfPyIsNone(result)) { extract e(result); if (e.check()) { - return boost::optional(e()); + return std::optional(e()); } else { TF_CODING_ERROR("ModifyItemEdits callback has " "incorrect return type."); } } - return boost::optional(); + return std::optional(); } private: diff --git a/pxr/usd/sdf/pyListOp.h b/pxr/usd/sdf/pyListOp.h index 2359bffa48..aab9017f5d 100644 --- a/pxr/usd/sdf/pyListOp.h +++ b/pxr/usd/sdf/pyListOp.h @@ -61,7 +61,7 @@ class SdfPyWrapListOp { } static boost::python::object _ApplyOperations2(const T& outer, const T& inner) { - if (boost::optional r = outer.ApplyOperations(inner)) { + if (std::optional r = outer.ApplyOperations(inner)) { return boost::python::object(*r); } else { return boost::python::object(); diff --git a/pxr/usd/sdf/relationshipSpec.cpp b/pxr/usd/sdf/relationshipSpec.cpp index 752de9b923..888487ef1e 100644 --- a/pxr/usd/sdf/relationshipSpec.cpp +++ b/pxr/usd/sdf/relationshipSpec.cpp @@ -39,6 +39,7 @@ #include "pxr/base/trace/trace.h" #include +#include PXR_NAMESPACE_OPEN_SCOPE @@ -145,7 +146,7 @@ SdfRelationshipSpec::ClearTargetPathList() const GetTargetPathList().ClearEdits(); } -static boost::optional +static std::optional _ReplacePath( const SdfPath &oldPath, const SdfPath &newPath, const SdfPath &path) { @@ -155,7 +156,7 @@ _ReplacePath( return newPath; } if (path == newPath) { - return boost::none; + return std::nullopt; } return path; } diff --git a/pxr/usd/sdf/vectorListEditor.h b/pxr/usd/sdf/vectorListEditor.h index efe2942d45..012b08193e 100644 --- a/pxr/usd/sdf/vectorListEditor.h +++ b/pxr/usd/sdf/vectorListEditor.h @@ -127,12 +127,12 @@ class Sdf_VectorListEditor private: static - boost::optional + std::optional _ModifyCallbackHelper(const ModifyCallback& cb, const TypePolicy& typePolicy, const value_type& v) { - boost::optional value = cb(v); + std::optional value = cb(v); return value ? typePolicy.Canonicalize(*value) : value; } diff --git a/pxr/usd/usd/flattenUtils.cpp b/pxr/usd/usd/flattenUtils.cpp index b4393ba784..fba30ce71e 100644 --- a/pxr/usd/usd/flattenUtils.cpp +++ b/pxr/usd/usd/flattenUtils.cpp @@ -51,6 +51,7 @@ #include #include +#include #include PXR_NAMESPACE_OPEN_SCOPE @@ -127,7 +128,7 @@ VtValue _Reduce(const SdfListOp &lhs, const SdfListOp &rhs) { // We assume the caller has already applied _FixListOp() - if (boost::optional> r = lhs.ApplyOperations(rhs)) { + if (std::optional> r = lhs.ApplyOperations(rhs)) { return VtValue(*r); } // The approximation used should always be composable, @@ -244,13 +245,13 @@ _ApplyLayerOffsetToClipInfo( } template -static boost::optional +static std::optional _ApplyLayerOffsetToRefOrPayload(const SdfLayerOffset &offset, const RefOrPayloadType &refOrPayload) { RefOrPayloadType result = refOrPayload; result.SetLayerOffset(offset * refOrPayload.GetLayerOffset()); - return boost::optional(result); + return std::optional(result); } // Apply layer offsets (time remapping) to time-keyed metadata. @@ -312,7 +313,7 @@ using _ResolveAssetPathFn = std::function< const std::string& assetPath)>; template -static boost::optional +static std::optional _FixReferenceOrPayload(const _ResolveAssetPathFn& resolveAssetPathFn, const SdfLayerHandle &sourceLayer, const RefOrPayloadType &refOrPayload) @@ -320,7 +321,7 @@ _FixReferenceOrPayload(const _ResolveAssetPathFn& resolveAssetPathFn, RefOrPayloadType result = refOrPayload; result.SetAssetPath( resolveAssetPathFn(sourceLayer, refOrPayload.GetAssetPath())); - return boost::optional(result); + return std::optional(result); } static void diff --git a/pxr/usd/usdUtils/assetLocalizationDelegate.cpp b/pxr/usd/usdUtils/assetLocalizationDelegate.cpp index f9344460f7..0c3c4a32bb 100644 --- a/pxr/usd/usdUtils/assetLocalizationDelegate.cpp +++ b/pxr/usd/usdUtils/assetLocalizationDelegate.cpp @@ -135,7 +135,7 @@ UsdUtils_WritableLocalizationDelegate::_ProcessReferencesOrPayloads( } template -boost::optional +std::optional UsdUtils_WritableLocalizationDelegate::_ProcessRefOrPayload( const SdfLayerRefPtr &layer, const RefOrPayloadType& refOrPayload, @@ -145,7 +145,7 @@ UsdUtils_WritableLocalizationDelegate::_ProcessRefOrPayload( // these since they refer to the same layer where the payload was // authored. if (refOrPayload.GetAssetPath().empty()) { - return boost::optional(refOrPayload); + return std::optional(refOrPayload); } UsdUtilsDependencyInfo depInfo(refOrPayload.GetAssetPath()); @@ -153,7 +153,7 @@ UsdUtils_WritableLocalizationDelegate::_ProcessRefOrPayload( layer, depInfo, DEP_TYPE); if (info.GetAssetPath().empty()) { - return boost::none; + return std::nullopt; } RefOrPayloadType processedRefOrPayload = refOrPayload; @@ -165,7 +165,7 @@ UsdUtils_WritableLocalizationDelegate::_ProcessRefOrPayload( dependencies->insert(dependencies->end(), info.GetDependencies().begin(), info.GetDependencies().end()); - return boost::optional(processedRefOrPayload); + return std::optional(processedRefOrPayload); } // When beginning to process a value, if the value is a dictionary, explicitly diff --git a/pxr/usd/usdUtils/assetLocalizationDelegate.h b/pxr/usd/usdUtils/assetLocalizationDelegate.h index 6112e18942..13c9124d12 100644 --- a/pxr/usd/usdUtils/assetLocalizationDelegate.h +++ b/pxr/usd/usdUtils/assetLocalizationDelegate.h @@ -204,7 +204,7 @@ class UsdUtils_WritableLocalizationDelegate const TfToken &listOpToken); template - boost::optional _ProcessRefOrPayload( + std::optional _ProcessRefOrPayload( const SdfLayerRefPtr &layer, const RefOrPayloadType& refOrPayload, std::vector* dependencies); diff --git a/pxr/usd/usdUtils/stitch.cpp b/pxr/usd/usdUtils/stitch.cpp index f61a009ab1..0e4911b86a 100644 --- a/pxr/usd/usdUtils/stitch.cpp +++ b/pxr/usd/usdUtils/stitch.cpp @@ -82,7 +82,7 @@ template VtValue _Reduce(const SdfListOp &stronger, const SdfListOp &weaker) { - boost::optional> r = stronger.ApplyOperations(weaker); + std::optional> r = stronger.ApplyOperations(weaker); if (r) { return VtValue(*r); }