Skip to content

Commit 70145ae

Browse files
authored
Merge pull request #1687 from bpmckinnon/ReplaceBoostAnyWithStdAny
Replace boost::any with std::any
2 parents 102e56d + c00edd5 commit 70145ae

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

openvdb/openvdb/io/Archive.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -330,10 +330,10 @@ namespace {
330330

331331
template<typename T>
332332
inline bool
333-
writeAsType(std::ostream& os, const boost::any& val)
333+
writeAsType(std::ostream& os, const std::any& val)
334334
{
335335
if (val.type() == typeid(T)) {
336-
os << boost::any_cast<T>(val);
336+
os << std::any_cast<T>(val);
337337
return true;
338338
}
339339
return false;
@@ -415,8 +415,8 @@ operator<<(std::ostream& os, const StreamMetadata::AuxDataMap& auxData)
415415
it != end; ++it)
416416
{
417417
os << it->first << ": ";
418-
// Note: boost::any doesn't support serialization.
419-
const boost::any& val = it->second;
418+
// Note: std::any doesn't support serialization.
419+
const std::any& val = it->second;
420420
if (!writeAsType<int32_t>(os, val)
421421
&& !writeAsType<int64_t>(os, val)
422422
&& !writeAsType<int16_t>(os, val)

openvdb/openvdb/io/io.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include <openvdb/Platform.h>
88
#include <openvdb/Types.h> // for SharedPtr
99
#include <openvdb/version.h>
10-
#include <boost/any.hpp>
10+
#include <any>
1111
#include <functional>
1212
#include <iosfwd> // for std::ios_base
1313
#include <map>
@@ -89,7 +89,7 @@ class OPENVDB_API StreamMetadata
8989
const MetaMap& gridMetadata() const;
9090
//@}
9191

92-
using AuxDataMap = std::map<std::string, boost::any>;
92+
using AuxDataMap = std::map<std::string, std::any>;
9393
//@{
9494
/// @brief Return a map that can be populated with arbitrary user data.
9595
AuxDataMap& auxData();

openvdb/openvdb/points/PointDataGrid.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,7 +1172,7 @@ PointDataLeafNode<T, Log2Dim>::readBuffers(std::istream& is, const CoordBBox& /*
11721172
std::string key("paged:" + std::to_string(index));
11731173
auto it = auxData.find(key);
11741174
if (it != auxData.end()) {
1175-
return *(boost::any_cast<compression::PagedInputStream::Ptr>(it->second));
1175+
return *(std::any_cast<compression::PagedInputStream::Ptr>(it->second));
11761176
}
11771177
else {
11781178
compression::PagedInputStream::Ptr pagedStream = std::make_shared<compression::PagedInputStream>();
@@ -1216,7 +1216,7 @@ PointDataLeafNode<T, Log2Dim>::readBuffers(std::istream& is, const CoordBBox& /*
12161216
std::string descriptorKey("descriptorPtr");
12171217
auto itDescriptor = auxData.find(descriptorKey);
12181218
assert(itDescriptor != auxData.end());
1219-
const Descriptor::Ptr descriptor = boost::any_cast<AttributeSet::Descriptor::Ptr>(itDescriptor->second);
1219+
const Descriptor::Ptr descriptor = std::any_cast<AttributeSet::Descriptor::Ptr>(itDescriptor->second);
12201220
return descriptor;
12211221
}
12221222
};
@@ -1338,7 +1338,7 @@ PointDataLeafNode<T, Log2Dim>::writeBuffers(std::ostream& os, bool toHalf) const
13381338
std::string key("paged:" + std::to_string(index));
13391339
auto it = auxData.find(key);
13401340
if (it != auxData.end()) {
1341-
compression::PagedOutputStream& stream = *(boost::any_cast<compression::PagedOutputStream::Ptr>(it->second));
1341+
compression::PagedOutputStream& stream = *(std::any_cast<compression::PagedOutputStream::Ptr>(it->second));
13421342
stream.flush();
13431343
(const_cast<io::StreamMetadata::AuxDataMap&>(auxData)).erase(it);
13441344
}
@@ -1350,7 +1350,7 @@ PointDataLeafNode<T, Log2Dim>::writeBuffers(std::ostream& os, bool toHalf) const
13501350
std::string key("paged:" + std::to_string(index));
13511351
auto it = auxData.find(key);
13521352
if (it != auxData.end()) {
1353-
return *(boost::any_cast<compression::PagedOutputStream::Ptr>(it->second));
1353+
return *(std::any_cast<compression::PagedOutputStream::Ptr>(it->second));
13541354
}
13551355
else {
13561356
compression::PagedOutputStream::Ptr pagedStream = std::make_shared<compression::PagedOutputStream>();
@@ -1374,12 +1374,12 @@ PointDataLeafNode<T, Log2Dim>::writeBuffers(std::ostream& os, bool toHalf) const
13741374
}
13751375
else {
13761376
// if matching bool is found and is false, early exit (a previous descriptor did not match)
1377-
bool matching = boost::any_cast<bool>(itMatching->second);
1377+
bool matching = std::any_cast<bool>(itMatching->second);
13781378
if (!matching) return;
13791379
assert(itDescriptor != auxData.end());
13801380
// if matching bool is true, check whether the existing descriptor matches the current one and set
13811381
// matching bool to false if not
1382-
const Descriptor::Ptr existingDescriptor = boost::any_cast<AttributeSet::Descriptor::Ptr>(itDescriptor->second);
1382+
const Descriptor::Ptr existingDescriptor = std::any_cast<AttributeSet::Descriptor::Ptr>(itDescriptor->second);
13831383
if (*existingDescriptor != *descriptor) {
13841384
(const_cast<io::StreamMetadata::AuxDataMap&>(auxData))[matchingKey] = false;
13851385
}
@@ -1393,7 +1393,7 @@ PointDataLeafNode<T, Log2Dim>::writeBuffers(std::ostream& os, bool toHalf) const
13931393
// if matching key is not found, no matching descriptor
13941394
if (itMatching == auxData.end()) return false;
13951395
// if matching key is found and is false, no matching descriptor
1396-
if (!boost::any_cast<bool>(itMatching->second)) return false;
1396+
if (!std::any_cast<bool>(itMatching->second)) return false;
13971397
return true;
13981398
}
13991399

@@ -1404,7 +1404,7 @@ PointDataLeafNode<T, Log2Dim>::writeBuffers(std::ostream& os, bool toHalf) const
14041404
// if matching key is true, however descriptor is not found, it has already been retrieved
14051405
if (itDescriptor == auxData.end()) return nullptr;
14061406
// otherwise remove it and return it
1407-
const Descriptor::Ptr descriptor = boost::any_cast<AttributeSet::Descriptor::Ptr>(itDescriptor->second);
1407+
const Descriptor::Ptr descriptor = std::any_cast<AttributeSet::Descriptor::Ptr>(itDescriptor->second);
14081408
(const_cast<io::StreamMetadata::AuxDataMap&>(auxData)).erase(itDescriptor);
14091409
return descriptor;
14101410
}

openvdb/openvdb/tools/VelocityFields.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ class VelocityIntegrator
229229
template<size_t OrderRK, typename LocationType>
230230
inline void rungeKutta(const ElementType dt, LocationType& world) const
231231
{
232-
BOOST_STATIC_ASSERT(OrderRK <= 4);
232+
static_assert(OrderRK <= 4);
233233
VecType P(static_cast<ElementType>(world[0]),
234234
static_cast<ElementType>(world[1]),
235235
static_cast<ElementType>(world[2]));

0 commit comments

Comments
 (0)