This is an automated email from the ASF dual-hosted git repository.

hulk pushed a commit to branch unstable
in repository https://gitbox.apache.org/repos/asf/kvrocks.git


The following commit(s) were added to refs/heads/unstable by this push:
     new 4bb6954c Refine ctor definition of CommandParser (#2044)
4bb6954c is described below

commit 4bb6954c837cfac605ce8ed77ab77b868432fa7b
Author: Twice <[email protected]>
AuthorDate: Fri Jan 26 12:17:36 2024 +0900

    Refine ctor definition of CommandParser (#2044)
---
 src/commands/command_parser.h | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/src/commands/command_parser.h b/src/commands/command_parser.h
index 3aa31ae0..c13d682b 100644
--- a/src/commands/command_parser.h
+++ b/src/commands/command_parser.h
@@ -24,10 +24,12 @@
 #include <cctype>
 #include <functional>
 #include <iterator>
+#include <type_traits>
 
 #include "parse_util.h"
 #include "status.h"
 #include "string_util.h"
+#include "type_util.h"
 
 template <typename Iter>
 struct MoveIterator : Iter {
@@ -46,17 +48,29 @@ struct CommandParser {
 
   CommandParser(Iter begin, Iter end) : begin_(std::move(begin)), 
end_(std::move(end)) {}
 
-  template <typename Container>
-  explicit CommandParser(const Container& con, size_t skip_num = 0) : 
CommandParser(std::begin(con), std::end(con)) {
+  template <typename Container, 
std::enable_if_t<std::is_lvalue_reference_v<Container> &&
+                                                     
!std::is_same_v<RemoveCVRef<Container>, CommandParser>,
+                                                 int> = 0>
+  explicit CommandParser(Container&& con, size_t skip_num = 0) : 
CommandParser(std::begin(con), std::end(con)) {
     std::advance(begin_, skip_num);
   }
 
-  template <typename Container>
+  template <typename Container, 
std::enable_if_t<!std::is_lvalue_reference_v<Container> &&
+                                                     
!std::is_same_v<RemoveCVRef<Container>, CommandParser>,
+                                                 int> = 0>
   explicit CommandParser(Container&& con, size_t skip_num = 0)
       : CommandParser(MoveIterator(std::begin(con)), 
MoveIterator(std::end(con))) {
     std::advance(begin_, skip_num);
   }
 
+  CommandParser(const CommandParser&) = default;
+  CommandParser(CommandParser&&) noexcept = default;
+
+  CommandParser& operator=(const CommandParser&) = default;
+  CommandParser& operator=(CommandParser&&) noexcept = default;
+
+  ~CommandParser() = default;
+
   decltype(auto) RawPeek() const { return *begin_; }
 
   decltype(auto) operator[](size_t index) const {

Reply via email to