In the first one, a temporary
std::string is initialised from the literal
"Unnamed" each time the function is called without an argument.
In the second case, the object
defaultName is initialised once (per source file), and simply used on each call.
- `std::variant` vs. inheritance vs. other ways (performance)
- Why is the construction of std::optional more expensive than a std::pair?
- Why are elementwise additions much faster in separate loops than in a combined loop?
- What are the new features in C++17?
- Why does GCC generate 15-20% faster code if I optimize for size instead of speed?
- How to write a large buffer into a binary file in C++, fast?
- Lambda capture as const reference?
- Is it better to use std::memcpy() or std::copy() in terms to performance?
- A fast method to round a double to a 32-bit int explained
- Why is processing an unsorted array the same speed as processing a sorted array with modern x86-64 clang?
- What is the advantage of using forwarding references in range-based for loops?
- Using scanf() in C++ programs is faster than using cin?
- Most elegant way to write a one-shot ‘if’
- Any optimization for random access on a very big array when the value in 95% of cases is either 0 or 1?
- How to overload std::swap()
- C++ performance challenge: integer to std::string conversion
- How does guaranteed copy elision work?
- Can const-correctness improve performance?
- Is multiplication faster than float division? [duplicate]
- Why is memmove faster than memcpy?
- When is a private constructor not a private constructor?
- Is accessing data in the heap faster than from the stack?
- fatal error: filesystem: No such file or directory [closed]
- Is a pointer with the right address and type still always a valid pointer since C++17?
- Is it allowed for a compiler to optimize away a local volatile variable?
- Why does my Intel Skylake / Kaby Lake CPU incur a mysterious factor 3 slowdown in a simple hash table implementation?
- What is the fastest way to change a key of an element inside std::map
- F# performance in scientific computing
- How the new range-based for loop in C++17 helps Ranges TS?
- Advantages of auto in template parameters in C++17
- How can I emulate destructuring in C++?
- boost serialization vs google protocol buffers? [closed]
- Why isn’t there a std::construct_at in C++17?
- Writing function definition in header files in C++
- Is integer multiplication really done at the same speed as addition on a modern CPU?
- Using AVX CPU instructions: Poor performance without “/arch:AVX”
- What is IACA and how do I use it?
- Strongly typed using and typedef
- Hashtable in C++?
- Simplest way to determine return type of function
- Is it possible in modern C++ to pass a string literal as a parameter to a C++ template?
- Non-intersecting line segments while minimizing the cumulative length
- mixing cout and printf for faster output
- Inserting into a vector at the front
- Use of observer_ptr
- What is the memory layout of vector of arrays?
- Does structured binding work with std::vector?
- Is the ranged based for loop beneficial to performance?
- Has the C++17 extension to aggregate initialization made brace initialization dangerous?
- Does the C++ standard guarantee that uniform initialization is exception-safe?