This repository was archived by the owner on Mar 28, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 5353#include < cassert>
5454#include < cstring>
5555#include < string>
56+ #include < tuple>
5657#include < utility>
5758
5859namespace llvm {
@@ -656,6 +657,33 @@ hash_code hash_value(const std::basic_string<T> &arg) {
656657 return hash_combine_range (arg.begin (), arg.end ());
657658}
658659
660+ template <unsigned ...Indices>
661+ struct UnsignedConstantIndexSet { };
662+
663+ template <unsigned I, unsigned N, unsigned ...Indices>
664+ struct MakeUnsignedConstantIndexSet {
665+ typedef typename MakeUnsignedConstantIndexSet<I+1 , N, Indices..., I>::Type
666+ Type;
667+ };
668+
669+ template <unsigned N, unsigned ...Indices>
670+ struct MakeUnsignedConstantIndexSet <N, N, Indices...> {
671+ typedef UnsignedConstantIndexSet<Indices...> Type;
672+ };
673+
674+ template <typename ...Ts, unsigned ...Indices>
675+ hash_code hash_value_tuple_helper (const std::tuple<Ts...> &arg,
676+ UnsignedConstantIndexSet<Indices...> indices) {
677+ return hash_combine (hash_value (std::get<Indices>(arg))...);
678+ }
679+
680+ template <typename ...Ts>
681+ hash_code hash_value (const std::tuple<Ts...> &arg) {
682+ return hash_value_tuple_helper (
683+ arg,
684+ typename MakeUnsignedConstantIndexSet<0 , sizeof ...(Ts)>::Type ());
685+ }
686+
659687} // namespace llvm
660688
661689#endif
You can’t perform that action at this time.
0 commit comments