Skip to content

Commit

Permalink
Change boost::unordered_set to std::unordered_set (#1634)
Browse files Browse the repository at this point in the history
  • Loading branch information
lballabio committed Apr 24, 2023
2 parents fc27348 + a998e67 commit 647528e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
6 changes: 6 additions & 0 deletions ql/models/shortrate/onefactormodels/gaussian1dmodel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@
#include <boost/math/bindings/rr.hpp>
#endif

#if BOOST_VERSION < 106700
#include <boost/functional/hash.hpp>
#else
#include <boost/container_hash/hash.hpp>
#endif

#include <boost/math/special_functions/erf.hpp>

#include <unordered_map>
Expand Down
22 changes: 18 additions & 4 deletions ql/patterns/observable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,24 @@ FOR A PARTICULAR PURPOSE. See the license for more details.
#include <ql/patterns/singleton.hpp>
#include <ql/shared_ptr.hpp>
#include <ql/types.hpp>
#include <boost/unordered_set.hpp>
#include <unordered_set>
#include <set>

#if !defined(QL_USE_STD_SHARED_PTR) && BOOST_VERSION < 107400

namespace std {

template<typename T>
struct hash<boost::shared_ptr<T>> {
std::size_t operator()(const boost::shared_ptr<T>& ptr) const noexcept {
return std::hash<typename boost::shared_ptr<T>::element_type*>()(ptr.get());
}
};

}

#endif

#ifndef QL_ENABLE_THREAD_SAFE_OBSERVER_PATTERN

namespace QuantLib {
Expand Down Expand Up @@ -100,7 +114,7 @@ namespace QuantLib {
/*! \ingroup patterns */
class Observer { // NOLINT(cppcoreguidelines-special-member-functions)
private:
typedef boost::unordered_set<ext::shared_ptr<Observable> > set_type;
typedef std::unordered_set<ext::shared_ptr<Observable>> set_type;
public:
typedef set_type::iterator iterator;

Expand Down Expand Up @@ -263,7 +277,7 @@ namespace QuantLib {
friend class Observable;
friend class ObservableSettings;
private:
typedef boost::unordered_set<ext::shared_ptr<Observable> > set_type;
typedef std::unordered_set<ext::shared_ptr<Observable>> set_type;
public:
typedef set_type::iterator iterator;

Expand Down Expand Up @@ -352,7 +366,7 @@ namespace QuantLib {
friend class Observer;
friend class ObservableSettings;
private:
typedef boost::unordered_set<ext::shared_ptr<Observer::Proxy>> set_type;
typedef std::unordered_set<ext::shared_ptr<Observer::Proxy>> set_type;
public:
typedef set_type::iterator iterator;

Expand Down
6 changes: 6 additions & 0 deletions ql/time/date.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@
#include <iomanip>
#include <ctime>

#if BOOST_VERSION < 106700
#include <boost/functional/hash.hpp>
#else
#include <boost/container_hash/hash.hpp>
#endif

#if defined(BOOST_NO_STDC_NAMESPACE)
namespace std { using ::time; using ::time_t; using ::tm;
using ::gmtime; using ::localtime; }
Expand Down

0 comments on commit 647528e

Please sign in to comment.