Skip to main content
3 votes
0 answers
205 views

I sometimes have function templates whose body consist of a single expression E, where the function's noexcept specifier should be noexcept(E). To my best knowledge, I need to repeat the invocation of ...
Sven Sandberg's user avatar
8 votes
2 answers
304 views

I haven't found a video about const all the things ¹, but there's at least Con.3: By default, pass pointers and references to consts from the Cpp Core Guidelines. There's lots of presentations and ...
Enlico's user avatar
  • 30.8k
4 votes
1 answer
141 views

In the following code, there is a no-throw operator new for the struct TestNew. It is required to further declare it as noexcept to ensure that the constructor is not called, when operator new returns ...
Hari's user avatar
  • 2,045
7 votes
1 answer
194 views

I have some code in the following style: struct S { private: T* resource; public: S(T* r) : resource{r} { if (r == nullptr) { throw std::invalid_argument(":("...
Jan Schultke's user avatar
  • 45.2k
5 votes
2 answers
155 views

I have the following C++26 function which runs some code for each field of a structure: template <typename S, typename F> constexpr auto for_each_field(S&& s, F&& f) { auto&...
Jean-Michaël Celerier's user avatar
4 votes
1 answer
206 views

In C++, I mark a function as noexcept in the following cases: The function itself does not throw exceptions, but its value type parameters may throw exceptions when constructing. The following code ...
Konvt's user avatar
  • 124
2 votes
1 answer
126 views

In the standard library, the parameter type of the exception class's constructor, such as std::runtime_error, follow this pattern: runtime_error( const std::string& what_arg ); // (1) ...
Konvt's user avatar
  • 124
0 votes
0 answers
83 views

I'm not sure if it is specified in the standard that advance/dereference of standard container iterator are noexcept. GCC and MSVC consistently make them noexcept for all standard containers. But ...
wanghan02's user avatar
  • 1,339
1 vote
0 answers
57 views

I have a mini-personal library that I am creating and I have a wrapper functor I created in order to easily go from static invocable objects to functors. For example, for something like std::...
Matias Grioni's user avatar
2 votes
1 answer
107 views

Let's say I have a class like this that can copy a value without throwing: #include <type_traits> template<typename T> requires std::is_nothrow_copy_constructible_v<T> &&...
Eternal's user avatar
  • 3,134
9 votes
1 answer
158 views

I have the following bit of code: #include <cmath> #include <stdexcept> #include <vector> void zoo(double& i) { std::vector<int> v(static_cast<std::size_t>(i)); }...
Penny Dreudter's user avatar
4 votes
2 answers
181 views

given the follow code: // g++ main.cpp -std=c++23 #include <type_traits> using namespace std; template<typename P> concept pointer_like = is_pointer_v<P> || requires (P p) { p....
DoZerg's user avatar
  • 323
0 votes
0 answers
90 views

Please tell me if I defined the conditions for noexcept expressions correctly in this cases? class scheme_host_port { public: using value_type = std::string; scheme_host_port()...
Tippa Toppa's user avatar
8 votes
2 answers
377 views

TL;DR: see compilers disagree on code by Godbolt link: https://godbolt.org/z/f7G6PTEsh Should std::variant be nothrow destructible when its alternative has potentially throwing destructor? Clang and ...
smitsyn's user avatar
  • 732
4 votes
1 answer
252 views

So I wanted to improve the noexcept of some operators and functions in my code can I mark this function noexcept ? std::string remove_suffix(/*passed by copy*/ std::string s) /*noexcept*/ // is ...
user avatar

15 30 50 per page
1
2 3 4 5
24