-
-
Notifications
You must be signed in to change notification settings - Fork 198
Closed
Description
Summary:
Functions like
inline void out_of_range(
const char* function,
int max,
int index,
const char* msg1 = "",
const char* msg2 = "");
uses const char* arguments where they should be using const std::string& in C++.
To avoid the performance hit of having to construct std::string instances when char* is being pased, we need to construct static standard strings in the calling functions:
static const std::string function_name = "foo";
static const std::string msg = "bar baz";
out_of_range(function_name, 5, 2, msg);
This way, each of the standard strings is only constructed once. They can't be constexpr and moved to compile time because std::string isn't a literal.
Current Version:
v2.13.0