CGRA-ME
Classes | Public Member Functions | List of all members
tuple_hash::TupleHashOps< Derived > Struct Template Reference

#include <TupleHash.h>

Classes

struct  Hash
 

Public Member Functions

const Derived & asDerived () const
 
Derived & asDerived ()
 
bool operator== (const Derived &rhs) const
 
bool operator< (const Derived &rhs) const
 

Detailed Description

template<typename Derived>
struct tuple_hash::TupleHashOps< Derived >

Help for making your simple struct hashable. Provides a constructor that takes one argument for each member exposed through asTuple().

ex:

struct MyStruct : tuple_hash::TupleHashOps<MyStruct> { // be sure update the template parameter to the base class int i,j;

MyStruct(int i, int j) : i(i), j(j) { } // required until c++17 (inheriting precludes aggregate property) auto asTuple() const { return std::make_tuple(i,j); } // all you have to do is provide this function. Retuning std::tie is fine. };

std::unordered_map<MyStruct, int, MyStruct::Hash> myMap; mySet.emplace(MyStruct{1,1}, 1);

Definition at line 94 of file TupleHash.h.

Member Function Documentation

◆ asDerived() [1/2]

template<typename Derived >
Derived& tuple_hash::TupleHashOps< Derived >::asDerived ( )
inline

Definition at line 96 of file TupleHash.h.

◆ asDerived() [2/2]

template<typename Derived >
const Derived& tuple_hash::TupleHashOps< Derived >::asDerived ( ) const
inline

Definition at line 95 of file TupleHash.h.

◆ operator<()

template<typename Derived >
bool tuple_hash::TupleHashOps< Derived >::operator< ( const Derived &  rhs) const
inline

Definition at line 99 of file TupleHash.h.

◆ operator==()

template<typename Derived >
bool tuple_hash::TupleHashOps< Derived >::operator== ( const Derived &  rhs) const
inline

Definition at line 98 of file TupleHash.h.


The documentation for this struct was generated from the following file: