Skip to content

Commit 09d344b

Browse files
authored
Merge pull request #1344 from johnhaddon/stdOptional
Replace `boost::optional` with `std::optional`
2 parents 4f7402d + 6b7d783 commit 09d344b

File tree

8 files changed

+31
-24
lines changed

8 files changed

+31
-24
lines changed

Changes

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
10.x.x.x (relative to 10.4.x.x)
2+
========
3+
4+
Breaking Changes
5+
----------------
6+
7+
- Primitive : Changed `variableIndexedView()` return type from `boost::optional` to `std::optional`.
8+
19
10.4.6.0 (relative to 10.4.5.0)
210
========
311

include/IECore/StreamIndexedIO.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
#include "IECore/VectorTypedData.h"
4242

4343
#include "boost/iostreams/filtering_stream.hpp"
44-
#include "boost/optional.hpp"
4544

4645
#include <fstream>
4746
#include <iostream>

include/IECoreScene/Primitive.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
#include "IECore/Canceller.h"
4343
#include "IECore/MessageHandler.h"
4444

45-
#include "boost/optional.hpp"
45+
#include <optional>
4646

4747
namespace IECoreScene
4848
{
@@ -73,7 +73,7 @@ class IECORESCENE_API Primitive : public VisibleRenderable
7373
/// If the required interpolation & datatype do not match then an empty optional is returned unless throwIfInvalid is true.
7474
/// The returned IndexedView lifetime must be bound by the primitive variable data it is viewing.
7575
template<typename T>
76-
boost::optional<PrimitiveVariable::IndexedView<typename T::ValueType::value_type>> variableIndexedView(
76+
std::optional<PrimitiveVariable::IndexedView<typename T::ValueType::value_type>> variableIndexedView(
7777
const std::string &name,
7878
PrimitiveVariable::Interpolation requiredInterpolation = PrimitiveVariable::Invalid,
7979
bool throwIfInvalid = false

include/IECoreScene/Primitive.inl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
namespace IECoreScene
3939
{
4040

41-
template<typename T> boost::optional<PrimitiveVariable::IndexedView < typename T::ValueType::value_type> >
41+
template<typename T> std::optional<PrimitiveVariable::IndexedView<typename T::ValueType::value_type>>
4242
Primitive::variableIndexedView( const std::string &name, PrimitiveVariable::Interpolation requiredInterpolation, bool throwIfInvalid ) const
4343
{
4444
PrimitiveVariableMap::const_iterator it = variables.find( name );
@@ -50,7 +50,7 @@ Primitive::variableIndexedView( const std::string &name, PrimitiveVariable::Inte
5050
}
5151
else
5252
{
53-
return boost::none;
53+
return std::nullopt;
5454
}
5555
}
5656

@@ -68,7 +68,7 @@ Primitive::variableIndexedView( const std::string &name, PrimitiveVariable::Inte
6868
}
6969
else
7070
{
71-
return boost::none;
71+
return std::nullopt;
7272
}
7373
}
7474

@@ -93,7 +93,7 @@ Primitive::variableIndexedView( const std::string &name, PrimitiveVariable::Inte
9393
}
9494
else
9595
{
96-
return boost::none;
96+
return std::nullopt;
9797
}
9898
}
9999

src/IECore/StreamIndexedIO.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@
5353
#include "boost/iostreams/filtering_stream.hpp"
5454
#include "boost/iostreams/filtering_streambuf.hpp"
5555
#include "boost/iostreams/stream.hpp"
56-
#include "boost/optional.hpp"
5756
#include "boost/tokenizer.hpp"
5857

5958
#include <algorithm>
6059
#include <cassert>
6160
#include <iostream>
6261
#include <list>
6362
#include <map>
63+
#include <optional>
6464
#include <set>
6565

6666
#include <fcntl.h>
@@ -415,11 +415,11 @@ size_t compress(
415415
int compressionLevel,
416416
const std::string &compressor,
417417
int threadCount,
418-
boost::optional<size_t> maxBlockSize = boost::optional<size_t>(),
418+
std::optional<size_t> maxBlockSize = std::optional<size_t>(),
419419
size_t minCompressedBlockSize = 1024U
420420
)
421421
{
422-
size_t maxCompressedBlockSize = maxBlockSize ? maxBlockSize.get() : BLOSC_MAX_BUFFERSIZE;
422+
const size_t maxCompressedBlockSize = maxBlockSize.value_or( BLOSC_MAX_BUFFERSIZE );
423423

424424
if( size < minCompressedBlockSize )
425425
{
@@ -765,7 +765,7 @@ class DirectoryNode : public NodeBase
765765
typedef std::vector< NodeBase* > ChildMap;
766766

767767
// regular constructor
768-
DirectoryNode(IndexedIO::EntryID name, boost::optional<uint32_t> numChildren = boost::optional<uint32_t>()) : NodeBase( NodeBase::Directory, name ),
768+
DirectoryNode(IndexedIO::EntryID name, std::optional<uint32_t> numChildren = std::optional<uint32_t>()) : NodeBase( NodeBase::Directory, name ),
769769
m_subindex( NoSubIndex ),
770770
m_sortedChildren( false ),
771771
m_subindexChildren( false ),
@@ -774,7 +774,7 @@ class DirectoryNode : public NodeBase
774774
{
775775
if ( numChildren )
776776
{
777-
m_children.reserve( numChildren.get() );
777+
m_children.reserve( *numChildren );
778778
}
779779

780780
}
@@ -1124,7 +1124,7 @@ class StreamIndexedIO::Index : public RefCounted
11241124
int m_compressionLevel;
11251125
int m_compressionThreadCount;
11261126
int m_decompressionThreadCount;
1127-
boost::optional<size_t> m_maxCompressedBlockSize;
1127+
std::optional<size_t> m_maxCompressedBlockSize;
11281128
std::string m_compressor;
11291129

11301130
struct FreePage

src/IECoreScene/MeshAlgoDistributePoints.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ struct Generator
160160
size_t v2I = v1I + 1;
161161

162162
Imath::V2f uv0, uv1, uv2;
163-
163+
164164
if( m_faceVaryingUVs )
165165
{
166166
uv0 = m_uvs[v0I];
@@ -232,7 +232,7 @@ PointsPrimitivePtr MeshAlgo::distributePoints( const MeshPrimitive *mesh, float
232232
MeshPrimitiveEvaluatorPtr meshEvaluator = new MeshPrimitiveEvaluator( updatedMesh );
233233

234234
bool faceVaryingUVs = true;
235-
boost::optional<PrimitiveVariable::IndexedView<V2f> > uvView = updatedMesh->variableIndexedView<V2fVectorData>( uvSet, PrimitiveVariable::FaceVarying, /* throwOnInvalid */ false );
235+
std::optional<PrimitiveVariable::IndexedView<V2f>> uvView = updatedMesh->variableIndexedView<V2fVectorData>( uvSet, PrimitiveVariable::FaceVarying, /* throwOnInvalid */ false );
236236
if( !uvView )
237237
{
238238
faceVaryingUVs = false;

src/IECoreScene/MeshAlgoFaceArea.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ PrimitiveVariable MeshAlgo::calculateFaceArea( const MeshPrimitive *mesh, const
9797
PrimitiveVariable MeshAlgo::calculateFaceTextureArea( const MeshPrimitive *mesh, const std::string &uvSet, const std::string &position, const Canceller *canceller )
9898
{
9999
PrimitiveVariable::Interpolation uvInterpolation = PrimitiveVariable::Vertex;
100-
boost::optional<PrimitiveVariable::IndexedView<V2f> > uvView = mesh->variableIndexedView<V2fVectorData>( uvSet, PrimitiveVariable::Vertex, false );
100+
std::optional<PrimitiveVariable::IndexedView<V2f>> uvView = mesh->variableIndexedView<V2fVectorData>( uvSet, PrimitiveVariable::Vertex, false );
101101
if( !uvView )
102102
{
103103
uvView = mesh->variableIndexedView<V2fVectorData>( uvSet, PrimitiveVariable::FaceVarying, false );

src/IECoreScene/bindings/PrimitiveBinding.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ void testVariableIndexedView()
7474

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

@@ -92,7 +92,7 @@ void testVariableIndexedView()
9292
}
9393

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

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

@@ -123,7 +123,7 @@ void testVariableIndexedView()
123123
bool exceptionRaised = false;
124124
try
125125
{
126-
boost::optional<PrimitiveVariable::IndexedView<Imath::V3f>> optionalIndexedView = primitive->variableIndexedView<IECore::V3fVectorData>(
126+
primitive->variableIndexedView<IECore::V3fVectorData>(
127127
"MISSING", IECoreScene::PrimitiveVariable::Interpolation::Vertex, true /* throwIfInvalid */
128128
);
129129
}
@@ -139,7 +139,7 @@ void testVariableIndexedView()
139139
// invalid interpolation
140140
{
141141
{
142-
boost::optional<PrimitiveVariable::IndexedView<Imath::V3f>> optionalIndexedView = primitive->variableIndexedView<IECore::V3fVectorData>(
142+
std::optional<PrimitiveVariable::IndexedView<Imath::V3f>> optionalIndexedView = primitive->variableIndexedView<IECore::V3fVectorData>(
143143
"P", IECoreScene::PrimitiveVariable::Interpolation::FaceVarying
144144
);
145145

@@ -149,7 +149,7 @@ void testVariableIndexedView()
149149
bool exceptionRaised = false;
150150
try
151151
{
152-
boost::optional<PrimitiveVariable::IndexedView<Imath::V3f>> optionalIndexedView = primitive->variableIndexedView<IECore::V3fVectorData>(
152+
primitive->variableIndexedView<IECore::V3fVectorData>(
153153
"P", IECoreScene::PrimitiveVariable::Interpolation::FaceVarying, true /* throwIfInvalid */
154154
);
155155
}
@@ -168,7 +168,7 @@ void testVariableIndexedView()
168168
// invalid type
169169
{
170170
{
171-
boost::optional<PrimitiveVariable::IndexedView<Imath::V2f>> optionalIndexedView = primitive->variableIndexedView<IECore::V2fVectorData>(
171+
std::optional<PrimitiveVariable::IndexedView<Imath::V2f>> optionalIndexedView = primitive->variableIndexedView<IECore::V2fVectorData>(
172172
"P", IECoreScene::PrimitiveVariable::Interpolation::Vertex
173173
);
174174

@@ -178,7 +178,7 @@ void testVariableIndexedView()
178178
bool exceptionRaised = false;
179179
try
180180
{
181-
boost::optional<PrimitiveVariable::IndexedView<Imath::V2f>> optionalIndexedView = primitive->variableIndexedView<IECore::V2fVectorData>(
181+
primitive->variableIndexedView<IECore::V2fVectorData>(
182182
"P", IECoreScene::PrimitiveVariable::Interpolation::Vertex, true /* throwIfInvalid */
183183
);
184184
}

0 commit comments

Comments
 (0)