@@ -18,10 +18,10 @@ class C10_API ConstantSymNodeImpl : public SymNodeImpl {
18
18
ConstantSymNodeImpl (T val) : value_(val) {}
19
19
20
20
bool is_int () override {
21
- return std::is_same<T, int64_t >::value ;
21
+ return is_int_ () ;
22
22
}
23
23
bool is_bool () override {
24
- return std::is_same<T, bool >::value ;
24
+ return is_bool_ () ;
25
25
}
26
26
bool is_float () override {
27
27
return false ;
@@ -55,21 +55,21 @@ class C10_API ConstantSymNodeImpl : public SymNodeImpl {
55
55
c10::SymNode lt (const c10::SymNode& other) override ;
56
56
c10::SymNode gt (const c10::SymNode& other) override ;
57
57
std::string str () override {
58
- if ( is_int ()) {
58
+ if constexpr ( is_int_ ()) {
59
59
return std::to_string (c10::get<int64_t >(value_));
60
60
} else {
61
61
return c10::get<bool >(value_) ? " true" : " false" ;
62
62
}
63
63
}
64
64
c10::optional<int64_t > constant_int () override {
65
- if ( is_int ()) {
65
+ if constexpr ( is_int_ ()) {
66
66
return c10::get<int64_t >(value_);
67
67
} else {
68
68
return c10::nullopt;
69
69
}
70
70
}
71
71
c10::optional<bool > constant_bool () override {
72
- if ( is_bool ()) {
72
+ if constexpr ( is_bool_ ()) {
73
73
return c10::get<bool >(value_);
74
74
} else {
75
75
return c10::nullopt;
@@ -84,6 +84,13 @@ class C10_API ConstantSymNodeImpl : public SymNodeImpl {
84
84
85
85
private:
86
86
c10::variant<int64_t , bool > value_;
87
+
88
+ static constexpr bool is_int_ () {
89
+ return std::is_same<T, int64_t >::value;
90
+ }
91
+ static constexpr bool is_bool_ () {
92
+ return std::is_same<T, bool >::value;
93
+ }
87
94
};
88
95
89
96
} // namespace c10
0 commit comments