Skip to content

clang-tidy: use make_unique #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions libxml++/parsers/parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,9 @@ void Parser::check_for_error_and_warning_messages()
}

if (validity_msg)
exception_.reset(new validity_error(msg));
exception_ = std::make_unique<validity_error>(msg);
else if (parser_msg)
exception_.reset(new parse_error(msg));
exception_ = std::make_unique<parse_error>(msg);
}

//static
Expand Down Expand Up @@ -331,7 +331,7 @@ void Parser::handle_exception()
#ifdef LIBXMLXX_HAVE_EXCEPTION_PTR
catch (...)
{
exception_.reset(new wrapped_exception(std::current_exception()));
exception_ = std::make_unique<wrapped_exception>(std::current_exception());
}
#else
catch (const std::exception& e)
Expand Down
2 changes: 1 addition & 1 deletion libxml++/parsers/saxparser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ void SaxParser::initialize_context()
{
Parser::initialize_context();
// Start with an empty Document for entity resolution.
entity_resolver_doc_.reset(new Document);
entity_resolver_doc_ = std::make_unique<Document>();
}


Expand Down
10 changes: 5 additions & 5 deletions libxml++/validators/validator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void Validator::check_for_validity_messages()
}

if (validity_msg)
exception_.reset(new validity_error(msg));
exception_ = std::make_unique<validity_error>(msg);
}

void Validator::callback_validity_error(void* valid_, const char* msg, ...)
Expand Down Expand Up @@ -130,17 +130,17 @@ void Validator::handle_exception()
#ifdef LIBXMLXX_HAVE_EXCEPTION_PTR
catch (...)
{
exception_.reset(new wrapped_exception(std::current_exception()));
exception_ = std::make_unique<wrapped_exception>(std::current_exception());
}
#else
catch (const std::exception& e)
{
exception_.reset(new exception(e.what()));
exception_ = std::make_unique<exception>(e.what());
}
catch (...)
{
exception_.reset(new exception("An exception was thrown that is not derived from std::exception or xmlpp::exception.\n"
"It could not be caught and rethrown because this platform does not support std::exception_ptr."));
exception_ = std::make_unique<exception>("An exception was thrown that is not derived from std::exception or xmlpp::exception.\n"
"It could not be caught and rethrown because this platform does not support std::exception_ptr.");
}
#endif

Expand Down