From 131e46e4c5fb75a89a3c6ad89f6dccc7ed38473c Mon Sep 17 00:00:00 2001 From: Richard Barnes Date: Sat, 28 Jun 2025 13:44:52 -0600 Subject: [PATCH] `throw()` -> `noexcept` (#3092) --- dlib/any/any_abstract.h | 2 +- dlib/cmd_line_parser/cmd_line_parser_check_1.h | 2 +- dlib/cmd_line_parser/cmd_line_parser_kernel_1.h | 2 +- dlib/config_reader/config_reader_kernel_1.h | 4 ++-- dlib/error.h | 6 +++--- dlib/misc_api/misc_api_kernel_1.h | 2 +- dlib/std_allocator.h | 14 +++++++------- dlib/svm/one_vs_all_trainer.h | 2 +- dlib/svm/one_vs_one_trainer.h | 2 +- dlib/type_safe_union/type_safe_union_kernel.h | 2 +- 10 files changed, 19 insertions(+), 19 deletions(-) diff --git a/dlib/any/any_abstract.h b/dlib/any/any_abstract.h index 3dcc069e1c..22eeb624c5 100644 --- a/dlib/any/any_abstract.h +++ b/dlib/any/any_abstract.h @@ -20,7 +20,7 @@ namespace dlib !*/ public: - virtual const char* what() const throw() { return "bad_any_cast"; } + virtual const char* what() const noexcept { return "bad_any_cast"; } }; // ---------------------------------------------------------------------------------------- diff --git a/dlib/cmd_line_parser/cmd_line_parser_check_1.h b/dlib/cmd_line_parser/cmd_line_parser_check_1.h index 1736b4b56a..49d33f1905 100644 --- a/dlib/cmd_line_parser/cmd_line_parser_check_1.h +++ b/dlib/cmd_line_parser/cmd_line_parser_check_1.h @@ -82,7 +82,7 @@ namespace dlib required_opts() { set_info_string(); } - ~cmd_line_check_error() throw() {} + ~cmd_line_check_error() noexcept {} void set_info_string ( ) diff --git a/dlib/cmd_line_parser/cmd_line_parser_kernel_1.h b/dlib/cmd_line_parser/cmd_line_parser_kernel_1.h index 2a1bef0702..12aa4e80a7 100644 --- a/dlib/cmd_line_parser/cmd_line_parser_kernel_1.h +++ b/dlib/cmd_line_parser/cmd_line_parser_kernel_1.h @@ -119,7 +119,7 @@ namespace dlib num(0) { set_info_string();} - ~cmd_line_parse_error() throw() {} + ~cmd_line_parse_error() noexcept {} const std::basic_string item; const unsigned long num; diff --git a/dlib/config_reader/config_reader_kernel_1.h b/dlib/config_reader/config_reader_kernel_1.h index c0f9e5a711..81ed473105 100644 --- a/dlib/config_reader/config_reader_kernel_1.h +++ b/dlib/config_reader/config_reader_kernel_1.h @@ -90,7 +90,7 @@ namespace dlib file_name(file_name_) {} - ~file_not_found() throw() {} + ~file_not_found() noexcept {} public: const std::string file_name; @@ -117,7 +117,7 @@ namespace dlib const_cast(info) = sout.str(); } - ~config_reader_access_error() throw() {} + ~config_reader_access_error() noexcept {} const std::string block_name; const std::string key_name; }; diff --git a/dlib/error.h b/dlib/error.h index 898019a99a..6beab7f966 100644 --- a/dlib/error.h +++ b/dlib/error.h @@ -105,14 +105,14 @@ namespace dlib !*/ virtual ~error( - ) throw() {} + ) noexcept {} /*! ensures - does nothing !*/ const char* what( - ) const throw() + ) const noexcept /*! ensures - if (info.size() != 0) then @@ -128,7 +128,7 @@ namespace dlib } const char* type_to_string ( - ) const throw() + ) const noexcept /*! ensures - returns a string that names the contents of the type member. diff --git a/dlib/misc_api/misc_api_kernel_1.h b/dlib/misc_api/misc_api_kernel_1.h index a500e992a1..636d306966 100644 --- a/dlib/misc_api/misc_api_kernel_1.h +++ b/dlib/misc_api/misc_api_kernel_1.h @@ -90,7 +90,7 @@ namespace dlib name(dir_name) {} - ~dir_create_error() throw() {} + ~dir_create_error() noexcept {} const std::string name; }; diff --git a/dlib/std_allocator.h b/dlib/std_allocator.h index b6e411c126..e45285ee8a 100644 --- a/dlib/std_allocator.h +++ b/dlib/std_allocator.h @@ -66,17 +66,17 @@ namespace dlib /*constructors and destructor *-nothing to do because the std_allocator has no state */ - std_allocator() throw() { } + std_allocator() noexcept { } - std_allocator(const std_allocator&) throw() { } + std_allocator(const std_allocator&) noexcept { } template - std_allocator (const std_allocator&) throw() { } + std_allocator (const std_allocator&) noexcept { } - ~std_allocator() throw() { } + ~std_allocator() noexcept { } //return maximum number of elements that can be allocated - size_type max_size () const throw() + size_type max_size () const noexcept { //for numeric_limits see Section 4.3, page 59 return std::numeric_limits::max() / sizeof(T); @@ -173,14 +173,14 @@ namespace dlib bool operator== ( const std_allocator&, const std_allocator& - ) throw() + ) noexcept { return std_alloc_compare::are_interchangeable; } template bool operator!= ( const std_allocator&, const std_allocator& - ) throw() + ) noexcept { return !std_alloc_compare::are_interchangeable; } // ---------------------------------------------------------------------------------------- diff --git a/dlib/svm/one_vs_all_trainer.h b/dlib/svm/one_vs_all_trainer.h index bcb006a414..3e5e711140 100644 --- a/dlib/svm/one_vs_all_trainer.h +++ b/dlib/svm/one_vs_all_trainer.h @@ -91,7 +91,7 @@ namespace dlib ) : dlib::error(msg), l(l_) {}; virtual ~invalid_label( - ) throw() {} + ) noexcept {} label_type l; }; diff --git a/dlib/svm/one_vs_one_trainer.h b/dlib/svm/one_vs_one_trainer.h index 2beec8f67a..f4951109c1 100644 --- a/dlib/svm/one_vs_one_trainer.h +++ b/dlib/svm/one_vs_one_trainer.h @@ -93,7 +93,7 @@ namespace dlib ) : dlib::error(msg), l1(l1_), l2(l2_) {}; virtual ~invalid_label( - ) throw() {} + ) noexcept {} label_type l1, l2; }; diff --git a/dlib/type_safe_union/type_safe_union_kernel.h b/dlib/type_safe_union/type_safe_union_kernel.h index e9ddf655bb..56adb81677 100644 --- a/dlib/type_safe_union/type_safe_union_kernel.h +++ b/dlib/type_safe_union/type_safe_union_kernel.h @@ -18,7 +18,7 @@ namespace dlib class bad_type_safe_union_cast : public std::bad_cast { public: - virtual const char * what() const throw() + virtual const char * what() const noexcept { return "bad_type_safe_union_cast"; }