From c288d8978d1c2b2c1436b9b9a3a13f63e5978860 Mon Sep 17 00:00:00 2001 From: blevin Date: Thu, 13 Jul 2017 16:23:12 -0700 Subject: [PATCH] Tf: Remove boost fallback for hash_{map,set} now that we assume c++11. This change caused some Python-related build issues in some other files on MacOS, which were fixed up as well. Fixes #127 (Internal change: 1765732) (Internal change: 1765736) (Internal change: 1765783) (Internal change: 1765909) --- pxr/base/lib/tf/hashmap.h | 204 +----------------- pxr/base/lib/tf/hashset.h | 200 +---------------- pxr/base/lib/tf/pyStaticTokens.h | 3 + .../lib/tf/wrapTestPyContainerConversions.cpp | 6 +- pxr/base/lib/tf/wrapTimeStamp.cpp | 5 +- pxr/usd/lib/sdf/wrapPath.cpp | 10 +- pxr/usd/lib/usdRi/wrapRmanUtilities.cpp | 3 + 7 files changed, 29 insertions(+), 402 deletions(-) diff --git a/pxr/base/lib/tf/hashmap.h b/pxr/base/lib/tf/hashmap.h index 6a2ff1958f..d89b7d7de2 100644 --- a/pxr/base/lib/tf/hashmap.h +++ b/pxr/base/lib/tf/hashmap.h @@ -27,24 +27,18 @@ // // Wrapping provides a convenient way to switch between implementations. // The GNU extension (currently) has the best overall performance but -// isn't standard. The boost implementation is widely available but -// slow. The standard implementation isn't available prior to C++11. +// isn't standard. Otherwise we use the C++11 standard implementation. #ifndef TF_HASHMAP_H #define TF_HASHMAP_H #include "pxr/pxr.h" -#if !defined(TF_NO_GNU_EXT) -// Use GNU extension. +#if !defined(TF_NO_GNU_EXT) // Use GNU extension. #include -#elif __cplusplus > 201103L -// Use C++11 unordered_map. +#else // Use C++11 unordered_map. #include -#else -// Use boost unordered_map. -#include -#endif // TF_NO_GNU_EXT +#endif // TF_NO_GNU_EXT PXR_NAMESPACE_OPEN_SCOPE @@ -264,7 +258,7 @@ class TfHashMultiMap : } }; -#elif __cplusplus > 201103L // C++11 +#else template, class EqualKey = std::equal_to, @@ -452,194 +446,6 @@ class TfHashMultiMap : const TfHashMap&); }; -#else - -template, - class EqualKey = std::equal_to, - class Alloc = std::allocator > > -class TfHashMap : - private boost::unordered_map { - typedef boost::unordered_map _Base; -public: - typedef typename _Base::key_type key_type; - typedef typename _Base::mapped_type mapped_type; - typedef typename _Base::value_type value_type; - typedef typename _Base::hasher hasher; - typedef typename _Base::key_equal key_equal; - typedef typename _Base::size_type size_type; - typedef typename _Base::difference_type difference_type; - typedef typename _Base::pointer pointer; - typedef typename _Base::const_pointer const_pointer; - typedef typename _Base::reference reference; - typedef typename _Base::const_reference const_reference; - typedef typename _Base::iterator iterator; - typedef typename _Base::const_iterator const_iterator; - typedef typename _Base::allocator_type allocator_type; - // No local_iterator nor any methods using them. - - TfHashMap() : _Base() { } - explicit - TfHashMap(size_type n, const hasher& hf = hasher(), - const key_equal& eql = key_equal(), - const allocator_type& alloc = allocator_type()) : - _Base(n, hf, eql, alloc) { } - explicit - TfHashMap(const allocator_type& alloc) : _Base(alloc) { } - template - TfHashMap(InputIterator first, InputIterator last, - size_type n = 0, const hasher& hf = hasher(), - const key_equal& eql = key_equal(), - const allocator_type& alloc = allocator_type()) : - _Base(first, last, n, hf, eql, alloc) { } - TfHashMap(const TfHashMap& other) : _Base(other) { } - - TfHashMap& operator=(const TfHashMap& rhs) { - _Base::operator=(rhs); - return *this; - } - - iterator begin() { return _Base::begin(); } - const_iterator begin() const { return _Base::begin(); } - // using _Base::bucket; - using _Base::bucket_count; - using _Base::bucket_size; - const_iterator cbegin() const { return _Base::cbegin(); } - const_iterator cend() const { return _Base::cend(); } - using _Base::clear; - using _Base::count; - using _Base::empty; - iterator end() { return _Base::end(); } - const_iterator end() const { return _Base::end(); } - using _Base::equal_range; - size_type erase(const key_type& key) { return _Base::erase(key); } - void erase(const_iterator position) { _Base::erase(position); } - void erase(const_iterator first, const_iterator last) { - _Base::erase(first, last); - } - using _Base::find; - using _Base::get_allocator; - using _Base::hash_function; - std::pair insert(const value_type& v) { - return _Base::insert(v); - } - iterator insert(const_iterator hint, const value_type& v) { - return _Base::insert(hint, v); - } - template - void insert(InputIterator first, InputIterator last) { - _Base::insert(first, last); - } - using _Base::key_eq; - using _Base::load_factor; - using _Base::max_bucket_count; - using _Base::max_load_factor; - // using _Base::max_load_factor; - using _Base::max_size; - using _Base::rehash; - using _Base::reserve; - using _Base::size; - void swap(TfHashMap& other) { _Base::swap(other); } - mapped_type& operator[](const key_type& k) { return _Base::operator[](k); } - - template - friend bool - operator==(const TfHashMap&, - const TfHashMap&); -}; - -template, - class EqualKey = std::equal_to, - class Alloc = std::allocator > > -class TfHashMultiMap : - private boost::unordered_map { - typedef boost::unordered_map _Base; -public: - typedef typename _Base::key_type key_type; - typedef typename _Base::mapped_type mapped_type; - typedef typename _Base::value_type value_type; - typedef typename _Base::hasher hasher; - typedef typename _Base::key_equal key_equal; - typedef typename _Base::size_type size_type; - typedef typename _Base::difference_type difference_type; - typedef typename _Base::pointer pointer; - typedef typename _Base::const_pointer const_pointer; - typedef typename _Base::reference reference; - typedef typename _Base::const_reference const_reference; - typedef typename _Base::iterator iterator; - typedef typename _Base::const_iterator const_iterator; - typedef typename _Base::allocator_type allocator_type; - // No local_iterator nor any methods using them. - - TfHashMultiMap() : _Base() { } - explicit - TfHashMultiMap(size_type n, const hasher& hf = hasher(), - const key_equal& eql = key_equal(), - const allocator_type& alloc = allocator_type()) : - _Base(n, hf, eql, alloc) { } - explicit - TfHashMultiMap(const allocator_type& alloc) : _Base(alloc) { } - template - TfHashMultiMap(InputIterator first, InputIterator last, - size_type n = 0, const hasher& hf = hasher(), - const key_equal& eql = key_equal(), - const allocator_type& alloc = allocator_type()) : - _Base(first, last, n, hf, eql, alloc) { } - TfHashMultiMap(const TfHashMultiMap& other) : _Base(other) { } - - TfHashMultiMap& operator=(const TfHashMultiMap& rhs) { - _Base::operator=(rhs); - return *this; - } - - iterator begin() { return _Base::begin(); } - const_iterator begin() const { return _Base::begin(); } - // using _Base::bucket; - using _Base::bucket_count; - using _Base::bucket_size; - const_iterator cbegin() const { return _Base::cbegin(); } - const_iterator cend() const { return _Base::cend(); } - using _Base::clear; - using _Base::count; - using _Base::empty; - iterator end() { return _Base::end(); } - const_iterator end() const { return _Base::end(); } - using _Base::equal_range; - size_type erase(const key_type& key) { return _Base::erase(key); } - void erase(const_iterator position) { _Base::erase(position); } - void erase(const_iterator first, const_iterator last) { - _Base::erase(first, last); - } - using _Base::find; - using _Base::get_allocator; - using _Base::hash_function; - iterator insert(const value_type& v) { - return _Base::insert(v); - } - iterator insert(const_iterator hint, const value_type& v) { - return _Base::insert(hint, v); - } - template - void insert(InputIterator first, InputIterator last) { - _Base::insert(first, last); - } - using _Base::key_eq; - using _Base::load_factor; - using _Base::max_bucket_count; - using _Base::max_load_factor; - // using _Base::max_load_factor; - using _Base::max_size; - using _Base::rehash; - using _Base::reserve; - using _Base::size; - void swap(TfHashMultiMap& other) { _Base::swap(other); } - mapped_type& operator[](const key_type& k) { return _Base::operator[](k); } - - template - friend bool - operator==(const TfHashMap&, - const TfHashMap&); -}; - #endif template diff --git a/pxr/base/lib/tf/hashset.h b/pxr/base/lib/tf/hashset.h index 96f58d0846..b246f7da9a 100644 --- a/pxr/base/lib/tf/hashset.h +++ b/pxr/base/lib/tf/hashset.h @@ -27,24 +27,18 @@ // // Wrapping provides a convenient way to switch between implementations. // The GNU extension (currently) has the best overall performance but -// isn't standard. The boost implementation is widely available but -// slow. The standard implementation isn't available prior to C++11. +// isn't standard. Otherwise we use the C++11 standard implementation. #ifndef TF_HASHSET_H #define TF_HASHSET_H #include "pxr/pxr.h" -#if !defined(TF_NO_GNU_EXT) -// Use GNU extension. +#if !defined(TF_NO_GNU_EXT) // Use GNU extension. #include -#elif __cplusplus > 201103L -// Use C++11 unordered_set. +#else // Use C++11 unordered_map. #include -#else -// Use boost unordered_set. -#include -#endif // TF_NO_GNU_EXT +#endif // TF_NO_GNU_EXT PXR_NAMESPACE_OPEN_SCOPE @@ -260,7 +254,7 @@ class TfHashMultiSet : } }; -#elif __cplusplus > 201103L // C++11 +#else template, class EqualKey = std::equal_to, @@ -444,190 +438,6 @@ class TfHashMultiSet : const TfHashMultiSet&); }; -#else - -template, - class EqualKey = std::equal_to, - class Alloc = std::allocator > -class TfHashSet : - private boost::unordered_set { - typedef boost::unordered_set _Base; -public: - typedef typename _Base::key_type key_type; - typedef typename _Base::value_type value_type; - typedef typename _Base::hasher hasher; - typedef typename _Base::key_equal key_equal; - typedef typename _Base::size_type size_type; - typedef typename _Base::difference_type difference_type; - typedef typename _Base::pointer pointer; - typedef typename _Base::const_pointer const_pointer; - typedef typename _Base::reference reference; - typedef typename _Base::const_reference const_reference; - typedef typename _Base::iterator iterator; - typedef typename _Base::const_iterator const_iterator; - typedef typename _Base::allocator_type allocator_type; - // No local_iterator nor any methods using them. - - TfHashSet() : _Base() { } - explicit - TfHashSet(size_type n, const hasher& hf = hasher(), - const key_equal& eql = key_equal(), - const allocator_type& alloc = allocator_type()) : - _Base(n, hf, eql, alloc) { } - explicit - TfHashSet(const allocator_type& alloc) : _Base(alloc) { } - template - TfHashSet(InputIterator first, InputIterator last, - size_type n = 0, const hasher& hf = hasher(), - const key_equal& eql = key_equal(), - const allocator_type& alloc = allocator_type()) : - _Base(first, last, n, hf, eql, alloc) { } - TfHashSet(const TfHashSet& other) : _Base(other) { } - - TfHashSet& operator=(const TfHashSet& rhs) { - _Base::operator=(rhs); - return *this; - } - - iterator begin() { return _Base::begin(); } - const_iterator begin() const { return _Base::begin(); } - // using _Base::bucket; - using _Base::bucket_count; - using _Base::bucket_size; - const_iterator cbegin() const { return _Base::cbegin(); } - const_iterator cend() const { return _Base::cend(); } - using _Base::clear; - using _Base::count; - using _Base::empty; - iterator end() { return _Base::end(); } - const_iterator end() const { return _Base::end(); } - using _Base::equal_range; - size_type erase(const key_type& key) { return _Base::erase(key); } - void erase(const_iterator position) { _Base::erase(position); } - void erase(const_iterator first, const_iterator last) { - _Base::erase(first, last); - } - using _Base::find; - using _Base::get_allocator; - using _Base::hash_function; - std::pair insert(const value_type& v) { - return _Base::insert(v); - } - iterator insert(const_iterator hint, const value_type& v) { - return _Base::insert(hint, v); - } - template - void insert(InputIterator first, InputIterator last) { - _Base::insert(first, last); - } - using _Base::key_eq; - using _Base::load_factor; - using _Base::max_bucket_count; - using _Base::max_load_factor; - // using _Base::max_load_factor; - using _Base::max_size; - using _Base::rehash; - using _Base::reserve; - using _Base::size; - void swap(TfHashSet& other) { _Base::swap(other); } - - template - friend bool - operator==(const TfHashSet&, - const TfHashSet&); -}; - -template, - class EqualKey = std::equal_to, - class Alloc = std::allocator > -class TfHashMultiSet : - private boost::unordered_multiset { - typedef boost::unordered_multiset _Base; -public: - typedef typename _Base::key_type key_type; - typedef typename _Base::value_type value_type; - typedef typename _Base::hasher hasher; - typedef typename _Base::key_equal key_equal; - typedef typename _Base::size_type size_type; - typedef typename _Base::difference_type difference_type; - typedef typename _Base::pointer pointer; - typedef typename _Base::const_pointer const_pointer; - typedef typename _Base::reference reference; - typedef typename _Base::const_reference const_reference; - typedef typename _Base::iterator iterator; - typedef typename _Base::const_iterator const_iterator; - typedef typename _Base::allocator_type allocator_type; - // No local_iterator nor any methods using them. - - TfHashMultiSet() : _Base() { } - explicit - TfHashMultiSet(size_type n, const hasher& hf = hasher(), - const key_equal& eql = key_equal(), - const allocator_type& alloc = allocator_type()) : - _Base(n, hf, eql, alloc) { } - explicit - TfHashMultiSet(const allocator_type& alloc) : _Base(alloc) { } - template - TfHashMultiSet(InputIterator first, InputIterator last, - size_type n = 0, const hasher& hf = hasher(), - const key_equal& eql = key_equal(), - const allocator_type& alloc = allocator_type()) : - _Base(first, last, n, hf, eql, alloc) { } - TfHashMultiSet(const TfHashMultiSet& other) : _Base(other) { } - - TfHashMultiSet& operator=(const TfHashMultiSet& rhs) { - _Base::operator=(rhs); - return *this; - } - - iterator begin() { return _Base::begin(); } - const_iterator begin() const { return _Base::begin(); } - // using _Base::bucket; - using _Base::bucket_count; - using _Base::bucket_size; - const_iterator cbegin() const { return _Base::cbegin(); } - const_iterator cend() const { return _Base::cend(); } - using _Base::clear; - using _Base::count; - using _Base::empty; - iterator end() { return _Base::end(); } - const_iterator end() const { return _Base::end(); } - using _Base::equal_range; - size_type erase(const key_type& key) { return _Base::erase(key); } - void erase(const_iterator position) { _Base::erase(position); } - void erase(const_iterator first, const_iterator last) { - _Base::erase(first, last); - } - using _Base::find; - using _Base::get_allocator; - using _Base::hash_function; - iterator insert(const value_type& v) { - return _Base::insert(v); - } - iterator insert(const_iterator hint, const value_type& v) { - return _Base::insert(hint, v); - } - template - void insert(InputIterator first, InputIterator last) { - _Base::insert(first, last); - } - using _Base::key_eq; - using _Base::load_factor; - using _Base::max_bucket_count; - using _Base::max_load_factor; - // using _Base::max_load_factor; - using _Base::max_size; - using _Base::rehash; - using _Base::reserve; - using _Base::size; - void swap(TfHashMultiSet& other) { _Base::swap(other); } - - template - friend bool - operator==(const TfHashMultiSet&, - const TfHashMultiSet&); -}; - #endif // TF_NO_GNU_EXT template diff --git a/pxr/base/lib/tf/pyStaticTokens.h b/pxr/base/lib/tf/pyStaticTokens.h index 7420e73058..e124135132 100644 --- a/pxr/base/lib/tf/pyStaticTokens.h +++ b/pxr/base/lib/tf/pyStaticTokens.h @@ -29,7 +29,10 @@ #include "pxr/pxr.h" +#include + #include "pxr/base/tf/staticTokens.h" + #include #include #include diff --git a/pxr/base/lib/tf/wrapTestPyContainerConversions.cpp b/pxr/base/lib/tf/wrapTestPyContainerConversions.cpp index 230e0628f0..d3139908fe 100644 --- a/pxr/base/lib/tf/wrapTestPyContainerConversions.cpp +++ b/pxr/base/lib/tf/wrapTestPyContainerConversions.cpp @@ -24,11 +24,13 @@ #include "pxr/pxr.h" +#include +#include +#include + #include "pxr/base/tf/token.h" #include -#include -#include using namespace boost::python; using std::pair; diff --git a/pxr/base/lib/tf/wrapTimeStamp.cpp b/pxr/base/lib/tf/wrapTimeStamp.cpp index 693050fabb..f6f33ea613 100644 --- a/pxr/base/lib/tf/wrapTimeStamp.cpp +++ b/pxr/base/lib/tf/wrapTimeStamp.cpp @@ -24,14 +24,15 @@ #include "pxr/pxr.h" +#include +#include + #include "pxr/base/tf/timeStamp.h" #include "pxr/base/tf/pyResultConversions.h" #include #include -#include - using std::string; using namespace boost::python; diff --git a/pxr/usd/lib/sdf/wrapPath.cpp b/pxr/usd/lib/sdf/wrapPath.cpp index 3e6ae366ea..1a3f50b0da 100644 --- a/pxr/usd/lib/sdf/wrapPath.cpp +++ b/pxr/usd/lib/sdf/wrapPath.cpp @@ -23,6 +23,12 @@ // #include "pxr/pxr.h" + +#include +#include +#include +#include + #include "pxr/usd/sdf/path.h" #include "pxr/base/tf/pyAnnotatedBoolResult.h" #include "pxr/base/tf/pyResultConversions.h" @@ -32,10 +38,6 @@ #include -#include -#include -#include - using namespace boost::python; using std::pair; using std::string; diff --git a/pxr/usd/lib/usdRi/wrapRmanUtilities.cpp b/pxr/usd/lib/usdRi/wrapRmanUtilities.cpp index 620e4ed60a..dd928393ac 100644 --- a/pxr/usd/lib/usdRi/wrapRmanUtilities.cpp +++ b/pxr/usd/lib/usdRi/wrapRmanUtilities.cpp @@ -22,6 +22,9 @@ // language governing permissions and limitations under the Apache License. // #include "pxr/pxr.h" + +#include + #include "pxr/usd/usdRi/rmanUtilities.h" #include "pxr/base/tf/token.h"