Skip to content

Commit

Permalink
Add workaround for rvalue reference overload issues in gcc 4.8.
Browse files Browse the repository at this point in the history
  • Loading branch information
tomfinegan committed Sep 6, 2019
1 parent dd5aaf0 commit 823b536
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ option(BUILD_FOR_GLTF "" OFF)
option(BUILD_MAYA_PLUGIN "Build plugin library for Maya." OFF)
option(BUILD_USD_PLUGIN "Build plugin library for USD." OFF)

if(${CMAKE_CXX_COMPILER_ID} MATCHES GNU
AND ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 5)
message(WARNING "GNU/GCC VERSION LESS THAN 5, ENABLING COMPATIBILITY MODE.")
draco_enable_feature(FEATURE "DRACO_OLD_GCC")
endif()

if(BUILD_FOR_GLTF)
# Override settings when building for GLTF.
draco_enable_feature(FEATURE "DRACO_MESH_COMPRESSION_SUPPORTED")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,11 @@ class DynamicIntegerPointsKdTreeDecoder {
// Decodes a integer point cloud from |buffer|.
template <class OutputIteratorT>
bool DecodePoints(DecoderBuffer *buffer, OutputIteratorT &oit);

#ifndef DRACO_OLD_GCC
template <class OutputIteratorT>
bool DecodePoints(DecoderBuffer *buffer, OutputIteratorT &&oit);
#endif // DRACO_OLD_GCC

const uint32_t dimension() const { return dimension_; }

Expand Down Expand Up @@ -138,13 +141,15 @@ class DynamicIntegerPointsKdTreeDecoder {
};

// Decodes a point cloud from |buffer|.
#ifndef DRACO_OLD_GCC
template <int compression_level_t>
template <class OutputIteratorT>
bool DynamicIntegerPointsKdTreeDecoder<compression_level_t>::DecodePoints(
DecoderBuffer *buffer, OutputIteratorT &&oit) {
OutputIteratorT local = std::forward<OutputIteratorT>(oit);
return DecodePoints(buffer, local);
}
#endif // DRACO_OLD_GCC

template <int compression_level_t>
template <class OutputIteratorT>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,12 @@ class FloatPointsTreeDecoder {
// Decodes a point cloud from |buffer|.
template <class OutputIteratorT>
bool DecodePointCloud(DecoderBuffer *buffer, OutputIteratorT &out);

#ifndef DRACO_OLD_GCC
template <class OutputIteratorT>
bool DecodePointCloud(DecoderBuffer *buffer, OutputIteratorT &&out);
#endif // BUILD_OLD_GCC

// Initializes a DecoderBuffer from |data|, and calls function above.
template <class OutputIteratorT>
bool DecodePointCloud(const char *data, size_t data_size,
Expand Down Expand Up @@ -72,12 +76,16 @@ class FloatPointsTreeDecoder {
uint32_t compression_level_;
};

#ifndef DRACO_OLD_GCC
// TODO(vytyaz): Reenable once USD migrates from GCC 4.8 to a higher version
// that can disambiguate calls to overloaded methods taking rvalue reference.
template <class OutputIteratorT>
bool FloatPointsTreeDecoder::DecodePointCloud(DecoderBuffer *buffer,
OutputIteratorT &&out) {
OutputIteratorT local = std::forward<OutputIteratorT>(out);
return DecodePointCloud(buffer, local);
}
#endif // BUILD_OLD_GCC

template <class OutputIteratorT>
bool FloatPointsTreeDecoder::DecodePointCloud(DecoderBuffer *buffer,
Expand Down

0 comments on commit 823b536

Please sign in to comment.