Add a utility function to Op that allows for checking if an operation has a specific trait.

PiperOrigin-RevId: 251489498
This commit is contained in:
River Riddle 2019-06-04 12:14:43 -07:00 committed by Mehdi Amini
parent 9b4a02c1e9
commit 11d18a4a5e
1 changed files with 7 additions and 0 deletions

View File

@ -749,6 +749,13 @@ class Op : public OpState,
typelist_contains<OpTrait::OneResult<ConcreteType>, OpState,
Traits<ConcreteType>...>::value> {
public:
/// Return if this operation contains the provided trait.
template <template <typename T> class Trait>
static constexpr bool hasTrait() {
return typelist_contains<Trait<ConcreteType>, OpState,
Traits<ConcreteType>...>::value;
}
/// Return the operation that this refers to.
Operation *getOperation() { return OpState::getOperation(); }