From 46d657a277f07233d0ee7a5522fc27d962922307 Mon Sep 17 00:00:00 2001 From: River Riddle Date: Mon, 27 May 2019 09:05:17 -0700 Subject: [PATCH] Move the 'is_detected' utility out of StorageUniquer and into STLExtras to allow reuse throughout the codebase. -- PiperOrigin-RevId: 250160508 --- mlir/include/mlir/Support/STLExtras.h | 21 ++++++++++++++ mlir/include/mlir/Support/StorageUniquer.h | 44 +++++++++--------------------- 2 files changed, 34 insertions(+), 31 deletions(-) diff --git a/mlir/include/mlir/Support/STLExtras.h b/mlir/include/mlir/Support/STLExtras.h index b99b09d..c9a5198 100644 --- a/mlir/include/mlir/Support/STLExtras.h +++ b/mlir/include/mlir/Support/STLExtras.h @@ -84,6 +84,27 @@ struct alignas(8) ClassID { return &id; } }; + +/// Utilities for detecting if a given trait holds for some set of arguments +/// 'Args'. For example, the given trait could be used to detect if a given type +/// has a copy assignment operator: +/// template +/// using has_copy_assign_t = decltype(std::declval() +/// = std::declval()); +/// bool fooHasCopyAssign = is_detected::value; +namespace detail { +template using void_t = void; +template class Op, class... Args> struct detector { + using value_t = std::false_type; +}; +template