Skip to content

Commit

Permalink
#1452 remove 'using vt::...' declarations polluting std namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakub Strzebonski committed Jan 7, 2022
1 parent 2faf14f commit e37fa47
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 42 deletions.
18 changes: 7 additions & 11 deletions src/vt/elm/elm_comm.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,25 +183,21 @@ using CommMapType = std::unordered_map<CommKeyType,CommVolume>;

namespace std {

using CommCategoryType = vt::elm::CommCategory;
using CommKeyType = vt::elm::CommKey;
using ElementIDStructType = vt::elm::ElementIDStruct;

template <>
struct hash<CommCategoryType> {
size_t operator()(CommCategoryType const& in) const {
using LBUnderType = typename std::underlying_type<CommCategoryType>::type;
struct hash<vt::elm::CommCategory> {
size_t operator()(vt::elm::CommCategory const& in) const {
using LBUnderType = std::underlying_type<vt::elm::CommCategory>::type;
auto const val = static_cast<LBUnderType>(in);
return std::hash<LBUnderType>()(val);
}
};

template <>
struct hash<CommKeyType> {
size_t operator()(CommKeyType const& in) const {
struct hash<vt::elm::CommKey> {
size_t operator()(vt::elm::CommKey const& in) const {
return std::hash<uint64_t>()(
std::hash<ElementIDStructType>()(in.from_) ^
std::hash<ElementIDStructType>()(in.to_) ^ in.nfrom_ ^ in.nto_
std::hash<vt::elm::ElementIDStruct>()(in.from_) ^
std::hash<vt::elm::ElementIDStruct>()(in.to_) ^ in.nfrom_ ^ in.nto_
);
}
};
Expand Down
21 changes: 10 additions & 11 deletions src/vt/rdma/channel/rdma_channel_lookup.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,17 @@ operator==(ChannelLookup const& c1, ChannelLookup const& c2) {
}} //end namespace vt::rdma

namespace std {
using RDMA_ChannelLookupType = vt::rdma::ChannelLookup;

template <>
struct hash<RDMA_ChannelLookupType> {
size_t operator()(RDMA_ChannelLookupType const& in) const {
auto const& combined =
std::hash<vt::RDMA_HandleType>()(in.handle) ^
std::hash<vt::NodeType>()(in.target) ^
std::hash<vt::NodeType>()(in.non_target);
return combined;
}
};
template <>
struct hash<vt::rdma::ChannelLookup> {
size_t operator()(vt::rdma::ChannelLookup const& in) const {
auto const& combined = std::hash<vt::RDMA_HandleType>()(in.handle) ^
std::hash<vt::NodeType>()(in.target) ^
std::hash<vt::NodeType>()(in.non_target);
return combined;
}
};

}

#endif /*INCLUDED_VT_RDMA_CHANNEL_RDMA_CHANNEL_LOOKUP_H*/
9 changes: 4 additions & 5 deletions src/vt/utils/memory/memory_units.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,11 @@ std::tuple<std::string, double> getBestMemoryUnit(std::size_t bytes);

namespace std {

using MemoryUnitType = vt::util::memory::MemoryUnitEnum;

template <>
struct hash<MemoryUnitType> {
size_t operator()(MemoryUnitType const& in) const {
using MemoryUnitUnderType = typename std::underlying_type<MemoryUnitType>::type;
struct hash<vt::util::memory::MemoryUnitEnum> {
size_t operator()(vt::util::memory::MemoryUnitEnum const& in) const {
using MemoryUnitUnderType =
std::underlying_type<vt::util::memory::MemoryUnitEnum>::type;
auto const val = static_cast<MemoryUnitUnderType>(in);
return std::hash<MemoryUnitUnderType>()(val);
}
Expand Down
9 changes: 4 additions & 5 deletions src/vt/vrt/collection/balance/lb_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,11 @@ enum struct LBType : int8_t {

namespace std {

using LBTypeType = vt::vrt::collection::balance::LBType;

template <>
struct hash<LBTypeType> {
size_t operator()(LBTypeType const& in) const {
using LBUnderType = typename std::underlying_type<LBTypeType>::type;
struct hash<vt::vrt::collection::balance::LBType> {
size_t operator()(vt::vrt::collection::balance::LBType const& in) const {
using LBUnderType =
std::underlying_type<vt::vrt::collection::balance::LBType>::type;
auto const val = static_cast<LBUnderType>(in);
return std::hash<LBUnderType>()(val);
}
Expand Down
19 changes: 9 additions & 10 deletions src/vt/vrt/proxy/base_elm_proxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,17 @@ struct BaseElmProxy {

}}} /* end namespace vt::vrt::collection */

namespace std {

template <typename IndexT>
using ElmType = ::vt::vrt::collection::BaseElmProxy<IndexT>;
struct hash<vt::vrt::collection::BaseElmProxy<IndexT>> {
size_t operator()(vt::vrt::collection::BaseElmProxy<IndexT> const& in) const {
using IndexType =
typename vt::vrt::collection::BaseElmProxy<IndexT>::IndexType;
return std::hash<IndexType>()(in.getIndex());
}
};

namespace std {
template <typename IndexT>
struct hash<ElmType<IndexT>> {
size_t operator()(ElmType<IndexT> const& in) const {
return std::hash<typename ElmType<IndexT>::IndexType>()(
in.getIndex()
);
}
};
}

#endif /*INCLUDED_VT_VRT_PROXY_BASE_ELM_PROXY_H*/

0 comments on commit e37fa47

Please sign in to comment.