aboutsummaryrefslogtreecommitdiff
path: root/src/argument_parser.cpp
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-03-14 18:02:18 +0100
committerHampusM <hampus@hampusmat.com>2022-06-13 17:56:56 +0200
commitdc6222611ad14a33f642396558ba84ecba9d6605 (patch)
treed759020233b66be62c5539209a03842d283b67a9 /src/argument_parser.cpp
parentdbab54ebf134b6ab2cf719d7c26a191fbffeed34 (diff)
perf: add noexcept almost everywhere
Diffstat (limited to 'src/argument_parser.cpp')
-rw-r--r--src/argument_parser.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/argument_parser.cpp b/src/argument_parser.cpp
index 16945f7..94c6a4a 100644
--- a/src/argument_parser.cpp
+++ b/src/argument_parser.cpp
@@ -9,7 +9,7 @@
namespace
{
-void optarg_error(char arg, const std::string_view &error)
+void optarg_error(char arg, const std::string_view &error) noexcept
{
std::cout << "Error: Invalid option argument for -" << arg << ". " << error
<< std::endl;
@@ -19,7 +19,7 @@ void optarg_error(char arg, const std::string_view &error)
/**
* Returns the current optarg as a string view.
*/
-std::string_view get_str_optarg()
+std::string_view get_str_optarg() noexcept
{
return std::string_view(optarg);
}
@@ -30,7 +30,7 @@ std::string_view get_str_optarg()
* @param arg The current command-line argument character
* @param check_zero Whether or not to make sure that the result is not zero
*/
-uint32_t get_uint_optarg(char arg, bool check_zero = false)
+uint32_t get_uint_optarg(char arg, bool check_zero = false) noexcept
{
auto conversion_result = str_to_uint(get_str_optarg());
@@ -44,16 +44,16 @@ uint32_t get_uint_optarg(char arg, bool check_zero = false)
} // namespace
ArgumentParser::ArgumentParser(
- IRandomNumberGeneratorFactory random_number_generator_factory)
+ IRandomNumberGeneratorFactory random_number_generator_factory) noexcept
: _random_number_generator_factory(random_number_generator_factory)
{
}
-ParsedArguments
-ArgumentParser::parse(const std::vector<option> &options,
- const std::string_view &short_options, const int &argc,
- char *const *argv) // NOLINT(cppcoreguidelines-avoid-c-arrays,
- // modernize-avoid-c-arrays)
+ParsedArguments ArgumentParser::parse(
+ const std::vector<option> &options, const std::string_view &short_options,
+ const int &argc,
+ char *const *argv) noexcept // NOLINT(cppcoreguidelines-avoid-c-arrays,
+ // modernize-avoid-c-arrays)
{
// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic)
const auto args = std::vector<std::string_view>(argv, argv + argc);