Skip to content

Commit

Permalink
Replace boost::optional with std::optional
Browse files Browse the repository at this point in the history
  • Loading branch information
johnhaddon committed Mar 20, 2023
1 parent 702fb14 commit 6b7d783
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 20 deletions.
8 changes: 8 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
10.x.x.x (relative to 10.4.x.x)
========

Breaking Changes
----------------

- Primitive : Changed `variableIndexedView()` return type from `boost::optional` to `std::optional`.

10.4.6.0 (relative to 10.4.5.0)
========

Expand Down
1 change: 0 additions & 1 deletion include/IECore/StreamIndexedIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
#include "IECore/VectorTypedData.h"

#include "boost/iostreams/filtering_stream.hpp"
#include "boost/optional.hpp"

#include <fstream>
#include <iostream>
Expand Down
4 changes: 2 additions & 2 deletions include/IECoreScene/Primitive.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#include "IECore/Canceller.h"
#include "IECore/MessageHandler.h"

#include "boost/optional.hpp"
#include <optional>

namespace IECoreScene
{
Expand Down Expand Up @@ -73,7 +73,7 @@ class IECORESCENE_API Primitive : public VisibleRenderable
/// If the required interpolation & datatype do not match then an empty optional is returned unless throwIfInvalid is true.
/// The returned IndexedView lifetime must be bound by the primitive variable data it is viewing.
template<typename T>
boost::optional<PrimitiveVariable::IndexedView<typename T::ValueType::value_type>> variableIndexedView(
std::optional<PrimitiveVariable::IndexedView<typename T::ValueType::value_type>> variableIndexedView(
const std::string &name,
PrimitiveVariable::Interpolation requiredInterpolation = PrimitiveVariable::Invalid,
bool throwIfInvalid = false
Expand Down
8 changes: 4 additions & 4 deletions include/IECoreScene/Primitive.inl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
namespace IECoreScene
{

template<typename T> boost::optional<PrimitiveVariable::IndexedView < typename T::ValueType::value_type> >
template<typename T> std::optional<PrimitiveVariable::IndexedView<typename T::ValueType::value_type>>
Primitive::variableIndexedView( const std::string &name, PrimitiveVariable::Interpolation requiredInterpolation, bool throwIfInvalid ) const
{
PrimitiveVariableMap::const_iterator it = variables.find( name );
Expand All @@ -50,7 +50,7 @@ Primitive::variableIndexedView( const std::string &name, PrimitiveVariable::Inte
}
else
{
return boost::none;
return std::nullopt;
}
}

Expand All @@ -68,7 +68,7 @@ Primitive::variableIndexedView( const std::string &name, PrimitiveVariable::Inte
}
else
{
return boost::none;
return std::nullopt;
}
}

Expand All @@ -93,7 +93,7 @@ Primitive::variableIndexedView( const std::string &name, PrimitiveVariable::Inte
}
else
{
return boost::none;
return std::nullopt;
}
}

Expand Down
12 changes: 6 additions & 6 deletions src/IECore/StreamIndexedIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@
#include "boost/iostreams/filtering_stream.hpp"
#include "boost/iostreams/filtering_streambuf.hpp"
#include "boost/iostreams/stream.hpp"
#include "boost/optional.hpp"
#include "boost/tokenizer.hpp"

#include <algorithm>
#include <cassert>
#include <iostream>
#include <list>
#include <map>
#include <optional>
#include <set>

#include <fcntl.h>
Expand Down Expand Up @@ -415,11 +415,11 @@ size_t compress(
int compressionLevel,
const std::string &compressor,
int threadCount,
boost::optional<size_t> maxBlockSize = boost::optional<size_t>(),
std::optional<size_t> maxBlockSize = std::optional<size_t>(),
size_t minCompressedBlockSize = 1024U
)
{
size_t maxCompressedBlockSize = maxBlockSize ? maxBlockSize.get() : BLOSC_MAX_BUFFERSIZE;
const size_t maxCompressedBlockSize = maxBlockSize.value_or( BLOSC_MAX_BUFFERSIZE );

if( size < minCompressedBlockSize )
{
Expand Down Expand Up @@ -765,7 +765,7 @@ class DirectoryNode : public NodeBase
typedef std::vector< NodeBase* > ChildMap;

// regular constructor
DirectoryNode(IndexedIO::EntryID name, boost::optional<uint32_t> numChildren = boost::optional<uint32_t>()) : NodeBase( NodeBase::Directory, name ),
DirectoryNode(IndexedIO::EntryID name, std::optional<uint32_t> numChildren = std::optional<uint32_t>()) : NodeBase( NodeBase::Directory, name ),
m_subindex( NoSubIndex ),
m_sortedChildren( false ),
m_subindexChildren( false ),
Expand All @@ -774,7 +774,7 @@ class DirectoryNode : public NodeBase
{
if ( numChildren )
{
m_children.reserve( numChildren.get() );
m_children.reserve( *numChildren );
}

}
Expand Down Expand Up @@ -1124,7 +1124,7 @@ class StreamIndexedIO::Index : public RefCounted
int m_compressionLevel;
int m_compressionThreadCount;
int m_decompressionThreadCount;
boost::optional<size_t> m_maxCompressedBlockSize;
std::optional<size_t> m_maxCompressedBlockSize;
std::string m_compressor;

struct FreePage
Expand Down
2 changes: 1 addition & 1 deletion src/IECoreScene/MeshAlgoDistributePoints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ PointsPrimitivePtr MeshAlgo::distributePoints( const MeshPrimitive *mesh, float
MeshPrimitiveEvaluatorPtr meshEvaluator = new MeshPrimitiveEvaluator( updatedMesh );

bool faceVaryingUVs = true;
boost::optional<PrimitiveVariable::IndexedView<V2f> > uvView = updatedMesh->variableIndexedView<V2fVectorData>( uvSet, PrimitiveVariable::FaceVarying, /* throwOnInvalid */ false );
std::optional<PrimitiveVariable::IndexedView<V2f>> uvView = updatedMesh->variableIndexedView<V2fVectorData>( uvSet, PrimitiveVariable::FaceVarying, /* throwOnInvalid */ false );
if( !uvView )
{
faceVaryingUVs = false;
Expand Down
2 changes: 1 addition & 1 deletion src/IECoreScene/MeshAlgoFaceArea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ PrimitiveVariable MeshAlgo::calculateFaceArea( const MeshPrimitive *mesh, const
PrimitiveVariable MeshAlgo::calculateFaceTextureArea( const MeshPrimitive *mesh, const std::string &uvSet, const std::string &position, const Canceller *canceller )
{
PrimitiveVariable::Interpolation uvInterpolation = PrimitiveVariable::Vertex;
boost::optional<PrimitiveVariable::IndexedView<V2f> > uvView = mesh->variableIndexedView<V2fVectorData>( uvSet, PrimitiveVariable::Vertex, false );
std::optional<PrimitiveVariable::IndexedView<V2f>> uvView = mesh->variableIndexedView<V2fVectorData>( uvSet, PrimitiveVariable::Vertex, false );
if( !uvView )
{
uvView = mesh->variableIndexedView<V2fVectorData>( uvSet, PrimitiveVariable::FaceVarying, false );
Expand Down
10 changes: 5 additions & 5 deletions src/IECoreScene/bindings/PrimitiveBinding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void testVariableIndexedView()

// check we get an view if type & interpolation are compatible
{
boost::optional<PrimitiveVariable::IndexedView<Imath::V3f>> optionalIndexedView = primitive->variableIndexedView<IECore::V3fVectorData>(
std::optional<PrimitiveVariable::IndexedView<Imath::V3f>> optionalIndexedView = primitive->variableIndexedView<IECore::V3fVectorData>(
"P", IECoreScene::PrimitiveVariable::Interpolation::Vertex
);

Expand All @@ -92,7 +92,7 @@ void testVariableIndexedView()
}

// If requiredInterpolation = Invalid matches any interpolation
boost::optional<PrimitiveVariable::IndexedView<Imath::V3f>> optionalIndexedView2 = primitive->variableIndexedView<IECore::V3fVectorData>(
std::optional<PrimitiveVariable::IndexedView<Imath::V3f>> optionalIndexedView2 = primitive->variableIndexedView<IECore::V3fVectorData>(
"P", IECoreScene::PrimitiveVariable::Interpolation::Invalid
);

Expand All @@ -113,7 +113,7 @@ void testVariableIndexedView()
// missing primvar
{
{
boost::optional<PrimitiveVariable::IndexedView<Imath::V3f>> optionalIndexedView = primitive->variableIndexedView<IECore::V3fVectorData>(
std::optional<PrimitiveVariable::IndexedView<Imath::V3f>> optionalIndexedView = primitive->variableIndexedView<IECore::V3fVectorData>(
"MISSING", IECoreScene::PrimitiveVariable::Interpolation::Vertex
);

Expand All @@ -139,7 +139,7 @@ void testVariableIndexedView()
// invalid interpolation
{
{
boost::optional<PrimitiveVariable::IndexedView<Imath::V3f>> optionalIndexedView = primitive->variableIndexedView<IECore::V3fVectorData>(
std::optional<PrimitiveVariable::IndexedView<Imath::V3f>> optionalIndexedView = primitive->variableIndexedView<IECore::V3fVectorData>(
"P", IECoreScene::PrimitiveVariable::Interpolation::FaceVarying
);

Expand Down Expand Up @@ -168,7 +168,7 @@ void testVariableIndexedView()
// invalid type
{
{
boost::optional<PrimitiveVariable::IndexedView<Imath::V2f>> optionalIndexedView = primitive->variableIndexedView<IECore::V2fVectorData>(
std::optional<PrimitiveVariable::IndexedView<Imath::V2f>> optionalIndexedView = primitive->variableIndexedView<IECore::V2fVectorData>(
"P", IECoreScene::PrimitiveVariable::Interpolation::Vertex
);

Expand Down

0 comments on commit 6b7d783

Please sign in to comment.