#pragma once // // This file is distributed under the MIT License. See LICENSE.md for details. // #include "revng/ADT/STLExtras.h" #include "revng/Support/Concepts.h" template struct KeyedObjectTraits { // static * key(const T &); // static T fromKey(* Key); }; // clang-format off template concept HasKeyObjectTraits = requires(T a) { { KeyedObjectTraits::key(a) }; { KeyedObjectTraits::fromKey(KeyedObjectTraits::key(a)) } -> same_as; }; // clang-format on /// Inherit if T is the key of itself template struct IdentityKeyedObjectTraits { static T key(const T &Obj) { return Obj; } static T fromKey(T Obj) { return Obj; } }; /// Trivial specialization for integral types template struct KeyedObjectTraits : public IdentityKeyedObjectTraits {}; static_assert(Integral); static_assert(HasKeyObjectTraits);