@@ -18,10 +18,10 @@ class C10_API ConstantSymNodeImpl : public SymNodeImpl {
1818 ConstantSymNodeImpl (T val) : value_(val) {}
1919
2020 bool is_int () override {
21- return std::is_same<T, int64_t >::value ;
21+ return is_int_ () ;
2222 }
2323 bool is_bool () override {
24- return std::is_same<T, bool >::value ;
24+ return is_bool_ () ;
2525 }
2626 bool is_float () override {
2727 return false ;
@@ -55,21 +55,21 @@ class C10_API ConstantSymNodeImpl : public SymNodeImpl {
5555 c10::SymNode lt (const c10::SymNode& other) override ;
5656 c10::SymNode gt (const c10::SymNode& other) override ;
5757 std::string str () override {
58- if ( is_int ()) {
58+ if constexpr ( is_int_ ()) {
5959 return std::to_string (c10::get<int64_t >(value_));
6060 } else {
6161 return c10::get<bool >(value_) ? " true" : " false" ;
6262 }
6363 }
6464 c10::optional<int64_t > constant_int () override {
65- if ( is_int ()) {
65+ if constexpr ( is_int_ ()) {
6666 return c10::get<int64_t >(value_);
6767 } else {
6868 return c10::nullopt ;
6969 }
7070 }
7171 c10::optional<bool > constant_bool () override {
72- if ( is_bool ()) {
72+ if constexpr ( is_bool_ ()) {
7373 return c10::get<bool >(value_);
7474 } else {
7575 return c10::nullopt ;
@@ -84,6 +84,13 @@ class C10_API ConstantSymNodeImpl : public SymNodeImpl {
8484
8585 private:
8686 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+ }
8794};
8895
8996} // namespace c10
0 commit comments