From 86b0f2d54677ee5781e048880c9a4e610dd90957 Mon Sep 17 00:00:00 2001 From: PragmaTwice Date: Mon, 22 Jan 2024 23:51:04 +0900 Subject: [PATCH 1/3] Refine ctor definition of CommandParser --- src/commands/command_parser.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/commands/command_parser.h b/src/commands/command_parser.h index 3aa31ae0931..36120e2dab9 100644 --- a/src/commands/command_parser.h +++ b/src/commands/command_parser.h @@ -24,6 +24,7 @@ #include #include #include +#include #include "parse_util.h" #include "status.h" @@ -46,17 +47,25 @@ struct CommandParser { CommandParser(Iter begin, Iter end) : begin_(std::move(begin)), end_(std::move(end)) {} - template - explicit CommandParser(const Container& con, size_t skip_num = 0) : CommandParser(std::begin(con), std::end(con)) { + template , int> = 0> + explicit CommandParser(Container&& con, size_t skip_num = 0) : CommandParser(std::begin(con), std::end(con)) { std::advance(begin_, skip_num); } - template + template , 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&&) = default; + + CommandParser& operator=(const CommandParser&) = default; + CommandParser& operator=(CommandParser&&) = default; + + ~CommandParser() = default; + decltype(auto) RawPeek() const { return *begin_; } decltype(auto) operator[](size_t index) const { From c8eb14ddddf1c6f50c61e14f0c4014da41b1ed20 Mon Sep 17 00:00:00 2001 From: PragmaTwice Date: Tue, 23 Jan 2024 07:30:21 +0900 Subject: [PATCH 2/3] fix --- src/commands/command_parser.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/commands/command_parser.h b/src/commands/command_parser.h index 36120e2dab9..c4b4ed0a0eb 100644 --- a/src/commands/command_parser.h +++ b/src/commands/command_parser.h @@ -47,12 +47,12 @@ struct CommandParser { CommandParser(Iter begin, Iter end) : begin_(std::move(begin)), end_(std::move(end)) {} - template , int> = 0> + template , int> = 0> explicit CommandParser(Container&& con, size_t skip_num = 0) : CommandParser(std::begin(con), std::end(con)) { std::advance(begin_, skip_num); } - template , int> = 0> + template , 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); From 33950bf4ff006d5bf97698898f9c29ebe565d831 Mon Sep 17 00:00:00 2001 From: PragmaTwice Date: Thu, 25 Jan 2024 23:16:27 +0900 Subject: [PATCH 3/3] fix --- src/commands/command_parser.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/commands/command_parser.h b/src/commands/command_parser.h index c4b4ed0a0eb..c13d682bdba 100644 --- a/src/commands/command_parser.h +++ b/src/commands/command_parser.h @@ -29,6 +29,7 @@ #include "parse_util.h" #include "status.h" #include "string_util.h" +#include "type_util.h" template struct MoveIterator : Iter { @@ -47,22 +48,26 @@ struct CommandParser { CommandParser(Iter begin, Iter end) : begin_(std::move(begin)), end_(std::move(end)) {} - template , int> = 0> + template && + !std::is_same_v, 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 , int> = 0> + template && + !std::is_same_v, 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&&) = default; + CommandParser(CommandParser&&) noexcept = default; CommandParser& operator=(const CommandParser&) = default; - CommandParser& operator=(CommandParser&&) = default; + CommandParser& operator=(CommandParser&&) noexcept = default; ~CommandParser() = default;