Skip to content

Commit 901eaee

Browse files
[Support] Consolidate has_FlowTraits in YAMLTraits.h (NFC) (#159241)
has_FlowTraits has two implementations: - "class has_FlowTraits" says false on non-class types. - "struct has_FlowTraits" checks for a "flow" member on class types. This patch eliminates the former because std::is_class is redundant if we are checking to see if &U::flow is well formed. The comment block being removed in this patch has been around since 2012. I'd assume that host compilers have improved since then. Note that we are now using is_detected, which wasn't the case back in 2012.
1 parent 2b2b580 commit 901eaee

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

llvm/include/llvm/Support/YAMLTraits.h

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -442,15 +442,8 @@ template <class T> struct has_CustomMappingTraits {
442442
is_detected<check, CustomMappingTraits<T>>::value;
443443
};
444444

445-
// has_FlowTraits<int> will cause an error with some compilers because
446-
// it subclasses int. Using this wrapper only instantiates the
447-
// real has_FlowTraits only if the template type is a class.
448-
template <typename T, bool Enabled = std::is_class_v<T>> class has_FlowTraits {
449-
public:
450-
static constexpr bool value = false;
451-
};
452-
453-
template <class T> struct has_FlowTraits<T, true> {
445+
// Test if flow is defined on type T.
446+
template <typename T> struct has_FlowTraits {
454447
template <class U> using check = decltype(&U::flow);
455448

456449
static constexpr bool value = is_detected<check, T>::value;

0 commit comments

Comments
 (0)