X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/77bbf3027c4240a2e833209a3a3f186589da8577..455a9c602ca8bf5bff5c942cbde83eb648318af1:/include/xbt/utility.hpp diff --git a/include/xbt/utility.hpp b/include/xbt/utility.hpp index e5776312f2..c39cf85725 100644 --- a/include/xbt/utility.hpp +++ b/include/xbt/utility.hpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016-2017. The SimGrid Team. +/* Copyright (c) 2016-2020. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -8,10 +8,28 @@ #define XBT_UTILITY_HPP #include +#include namespace simgrid { namespace xbt { +/** @brief A hash which works with more stuff + * + * It can hash pairs: the standard hash currently doesn't include this. + */ +template class hash : public std::hash { +}; + +template class hash> { +public: + std::size_t operator()(std::pair const& x) const + { + hash h1; + hash h2; + return h1(x.first) ^ h2(x.second); + } +}; + /** @brief Comparator class for using with std::priority_queue or boost::heap. * * Compare two std::pair by their first element (of type double), and return true when the first is greater than the @@ -22,6 +40,13 @@ public: bool operator()(const Pair& a, const Pair& b) const { return a.first > b.first; } }; +/** @brief Erase an element given by reference from a boost::intrusive::list. + */ +template inline void intrusive_erase(List& list, Elem& elem) +{ + list.erase(list.iterator_to(elem)); +} + // integer_sequence and friends from C++14 // We need them to implement `apply` from C++17. @@ -50,10 +75,6 @@ public: */ template class integer_sequence { - static constexpr std::size_t size() - { - return std::tuple_size::value; - } }; namespace bits {