Copilot commented on code in PR #3116:
URL: https://github.com/apache/brpc/pull/3116#discussion_r2425113691


##########
src/bvar/reducer.h:
##########
@@ -205,34 +319,55 @@ inline Reducer<T, Op, InvOp>& Reducer<T, Op, 
InvOp>::operator<<(
 namespace detail {
 template <typename Tp>
 struct AddTo {
-    void operator()(Tp & lhs, 
+    void operator()(Tp & lhs,
                     typename butil::add_cr_non_integral<Tp>::type rhs) const
     { lhs += rhs; }
 };
 template <typename Tp>
 struct MinusFrom {
-    void operator()(Tp & lhs, 
+    void operator()(Tp & lhs,
                     typename butil::add_cr_non_integral<Tp>::type rhs) const
     { lhs -= rhs; }
 };
-}
-template <typename T>
+} // namespace detail
+
+template <typename T, typename = void>
 class Adder : public Reducer<T, detail::AddTo<T>, detail::MinusFrom<T> > {
 public:
     typedef Reducer<T, detail::AddTo<T>, detail::MinusFrom<T> > Base;
     typedef T value_type;
     typedef typename Base::sampler_type sampler_type;
-public:
+
     Adder() : Base() {}
-    explicit Adder(const butil::StringPiece& name) : Base() {
+    Adder(const butil::StringPiece& name) : Base() {
         this->expose(name);
     }
     Adder(const butil::StringPiece& prefix,
           const butil::StringPiece& name) : Base() {
         this->expose_as(prefix, name);
     }
-    ~Adder() { Variable::hide(); }
+    ~Adder() override { Variable::hide(); }
+};
+
+#if WITH_BABYLON_COUNTER
+// Numerical types supported by babylon counter.
+template <typename T>
+class Adder<T, 
std::enable_if<std::is_constructible<babylon::GenericsConcurrentAdder<T>>::value>>

Review Comment:
   The template specialization is missing the second template parameter type. 
Should be 
`std::enable_if<std::is_constructible<babylon::GenericsConcurrentAdder<T>>::value>::type`.
   ```suggestion
   class Adder<T, typename 
std::enable_if<std::is_constructible<babylon::GenericsConcurrentAdder<T>>::value>::type>
   ```



##########
src/bvar/reducer.h:
##########
@@ -283,41 +421,112 @@ class Maxer : public Reducer<T, detail::MaxTo<T> > {
     }
 };
 
+#if WITH_BABYLON_COUNTER
+namespace detail {
+template <typename T>
+class ConcurrentMaxer : public babylon::GenericsConcurrentMaxer<T> {
+    typedef babylon::GenericsConcurrentMaxer<T> Base;
+public:
+    ConcurrentMaxer() = default;
+    ConcurrentMaxer(T default_value) : _default_value(default_value) {}
+
+    T value() const {
+        T result;
+        if (!Base::value(result)) {
+            return _default_value;
+        }
+        return std::max(result, _default_value);
+    }
+private:
+    T _default_value{0};
+};
+} // namespace detail
+
+// Numerical types supported by babylon counter.
+template <typename T>
+class Maxer<T, 
std::enable_if<std::is_constructible<detail::ConcurrentMaxer<T>>::value>>

Review Comment:
   The template specialization is missing the second template parameter type. 
Should be 
`std::enable_if<std::is_constructible<detail::ConcurrentMaxer<T>>::value>::type`.
   ```suggestion
   class Maxer<T, typename 
std::enable_if<std::is_constructible<detail::ConcurrentMaxer<T>>::value>::type>
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to