Skip to content

Commit

Permalink
Resrict some private methods to R-value.
Browse files Browse the repository at this point in the history
  • Loading branch information
oo13 committed Jul 12, 2024
1 parent 471cc6f commit a477000
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions include/tphrase/Generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -356,12 +356,12 @@ namespace tphrase {
/** The function used by Generator.
\return An instance of a type not to be published for the library users.
*/
DataSyntax &&move_syntax_data();
DataSyntax &&move_syntax_data() &&;

/** The function used by Generator.
\return The error messages that have been generated after creating the instance or clearing the previous error messages.
*/
std::string &&move_error_message();
std::string &&move_error_message() &&;

private:
struct Impl;
Expand Down
8 changes: 4 additions & 4 deletions src/Generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ namespace tphrase {
}

Generator::Generator(Syntax &&syntax, const std::string &start_condition)
: pimpl{new Impl{syntax.move_error_message()}}
: pimpl{new Impl{std::move(syntax).move_error_message()}}
{
pimpl->data.add(syntax.move_syntax_data(),
pimpl->data.add(std::move(syntax).move_syntax_data(),
start_condition,
pimpl->err_msg);
}
Expand Down Expand Up @@ -175,8 +175,8 @@ namespace tphrase {
bool Generator::add(Syntax &&syntax, const std::string &start_condition)
{
const std::size_t prev_len{pimpl->err_msg.size()};
pimpl->err_msg += syntax.get_error_message();
if (!pimpl->data.add(syntax.move_syntax_data(),
pimpl->err_msg += std::move(syntax).move_error_message();
if (!pimpl->data.add(std::move(syntax).move_syntax_data(),
start_condition,
pimpl->err_msg)) {
return false;
Expand Down
4 changes: 2 additions & 2 deletions src/Syntax.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,12 @@ namespace tphrase {
return pimpl->data;
}

DataSyntax &&Syntax::move_syntax_data()
DataSyntax &&Syntax::move_syntax_data() &&
{
return std::move(pimpl->data);
}

std::string &&Syntax::move_error_message()
std::string &&Syntax::move_error_message() &&
{
return std::move(pimpl->err_msg);
}
Expand Down

0 comments on commit a477000

Please sign in to comment.