diff --git a/src/commands/command_parser.h b/src/commands/command_parser.h index 3aa31ae0931..c13d682bdba 100644 --- a/src/commands/command_parser.h +++ b/src/commands/command_parser.h @@ -24,10 +24,12 @@ #include #include #include +#include #include "parse_util.h" #include "status.h" #include "string_util.h" +#include "type_util.h" template struct MoveIterator : Iter { @@ -46,17 +48,29 @@ 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 && + !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 + 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&&) 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 {