Skip to content

Commit

Permalink
doc: types in namesapce std
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean-Baptiste Rouquier committed Dec 16, 2024
1 parent f62673e commit 6660a24
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 1 deletion.
6 changes: 5 additions & 1 deletion include/hpcombi/epu8_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -553,20 +553,23 @@ inline std::string to_string(HPCombi::epu8 const &a) {
return ss.str();
}

//! This type appears in the doc because we provide an equal operator for HPCombi::epu8.
template <> struct equal_to<HPCombi::epu8> {
bool operator()(const HPCombi::epu8 &lhs,
const HPCombi::epu8 &rhs) const noexcept {
return HPCombi::equal(lhs, rhs);
}
};

//! This type appears in the doc because we provide a not_equal operator for HPCombi::epu8.
template <> struct not_equal_to<HPCombi::epu8> {
bool operator()(const HPCombi::epu8 &lhs,
const HPCombi::epu8 &rhs) const noexcept {
return HPCombi::not_equal(lhs, rhs);
}
};

//! This type appears in the doc because we provide a hash function for HPCombi::epu8.
template <> struct hash<HPCombi::epu8> {
inline size_t operator()(HPCombi::epu8 a) const noexcept {
unsigned __int128 v0 = simde_mm_extract_epi64(a, 0);
Expand All @@ -583,10 +586,11 @@ template <> struct hash<HPCombi::epu8> {
}
};

//! This type appears in the doc because we provide a less operator for HPCombi::epu8.
template <> struct less<HPCombi::epu8> {
// WARNING: due to endianness this is not lexicographic comparison,
// but we don't care when using in std::set.
// 10% faster than calling the lexicographic comparison operator !
// 10% faster than calling the lexicographic comparison operator!
inline size_t operator()(const HPCombi::epu8 &v1,
const HPCombi::epu8 &v2) const noexcept {
simde__m128 v1v = simde__m128(v1), v2v = simde__m128(v2);
Expand Down
5 changes: 5 additions & 0 deletions include/hpcombi/perm16.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -459,28 +459,33 @@ static_assert(std::is_trivial<Perm16>(), "Perm16 is not a trivial class !");
#include "perm16_impl.hpp"

namespace std {
// Hash operators for Transf and Perm:

//! This type appears in the doc because we provide a hash function for HPCombi::PTransf16.
template <> struct hash<HPCombi::PTransf16> {
//! A hash operator for #HPCombi::PTransf16
size_t operator()(const HPCombi::PTransf16 &ar) const {
return std::hash<HPCombi::epu8>{}(ar.v);
}
};

//! This type appears in the doc because we provide a hash function for HPCombi::Transf16.
template <> struct hash<HPCombi::Transf16> {
//! A hash operator for #HPCombi::Transf16
size_t operator()(const HPCombi::Transf16 &ar) const {
return uint64_t(ar);
}
};

//! This type appears in the doc because we provide a hash function for HPCombi::PPerm16.
template <> struct hash<HPCombi::PPerm16> {
//! A hash operator for #HPCombi::PPerm16
size_t operator()(const HPCombi::PPerm16 &ar) const {
return std::hash<HPCombi::epu8>{}(ar.v);
}
};

//! This type appears in the doc because we provide a hash function for HPCombi::Perm16.
template <> struct hash<HPCombi::Perm16> {
//! A hash operator for #HPCombi::Perm16
size_t operator()(const HPCombi::Perm16 &ar) const { return uint64_t(ar); }
Expand Down
1 change: 1 addition & 0 deletions include/hpcombi/perm_generic_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ bool PermGeneric<Size, Expo>::left_weak_leq(PermGeneric other) const {

namespace std {

//! This type appears in the doc because we provide a hash function for HPCombi::PermGeneric.
template <size_t Size, typename Expo>
struct hash<HPCombi::PermGeneric<Size, Expo>> {
size_t operator()(const HPCombi::PermGeneric<Size, Expo> &ar) const {
Expand Down
1 change: 1 addition & 0 deletions include/hpcombi/vect16.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ inline std::ostream &operator<<(std::ostream &stream,
return operator<<(stream, ar.v);
}

//! This type appears in the doc because we provide a hash function for HPCombi::Vect16.
template <> struct hash<HPCombi::Vect16> {
size_t operator()(const HPCombi::Vect16 &ar) const {
return std::hash<HPCombi::epu8>{}(ar.v);
Expand Down
1 change: 1 addition & 0 deletions include/hpcombi/vect_generic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ std::ostream &operator<<(std::ostream &stream,
return stream;
}

//! This type appears in the doc because we provide a hash function for HPCombi::VectGeneric.
template <size_t Size, typename Expo>
struct hash<HPCombi::VectGeneric<Size, Expo>> {
size_t operator()(const HPCombi::VectGeneric<Size, Expo> &ar) const {
Expand Down

0 comments on commit 6660a24

Please sign in to comment.