Skip to main content
Filter by
Sorted by
Tagged with
2 votes
0 answers
212 views

From cppreference: URVO is mandatory and no longer considered a form of copy elision. When copy elision occurs, the implementation treats the source and target of the omitted copy/move(since C++11) ...
Elucidase's user avatar
  • 197
2 votes
1 answer
285 views

I'm confused about the lifecycle of objects involved in prvalue semantics. For example: struct A { int *num; A(): num{new int(1)} {} A(A &&other) { num = std::move(other.num); std::cout &...
Elucidase's user avatar
  • 197
-2 votes
1 answer
701 views

What is the precedence and associativity of operators in C++? Who defines operator precedence and associativity, and how does it relate to order of evaluation? explains how those properties emerge ...
Jan Schultke's user avatar
  • 45.2k
12 votes
1 answer
3k views

There are plenty of questions and answers relating to C++ global variables, such as: static and extern global variables in C and C++ Global variables and constexpr (inline or not?) Is there any sense ...
Jan Schultke's user avatar
  • 45.2k
24 votes
1 answer
10k views

Over the past year or so I've noticed a few C++-related answers on StackOverflow refer to mdspan's - but I've never actually seen these in C++ code. I tried looking for them in my C++ compiler's ...
einpoklum's user avatar
  • 140k
46 votes
1 answer
35k views

In one of the most respected stackoverflow answer I found an example of std::expected template class usages: What are coroutines in C++20? At the same time I cannot find any mentioning of this class ...
Fedor's user avatar
  • 25.7k
10 votes
2 answers
4k views

I find very frustrating to have to fix C++ errors happening at linkage time (especially undefined reference errors) due to the fact that all the function names are mangled. An example of mangled name: ...
Javier Vilarroig's user avatar
4 votes
1 answer
368 views

There are some predefined preprocessor macros (specified in C and C++ standard) like __line__ and __file__ which are replaced by line number and file name during preprocessing respectively. In C++20, ...
Akib Azmain Turja's user avatar
17 votes
1 answer
3k views

I'm trying to make a class that will be both input and output stream (like std::cout and std::cin ). I tried to overload operator << and >>, but then, I understood that writing such code ...
Akib Azmain Turja's user avatar
6 votes
1 answer
410 views

Suppose I want to make a new deduction guide making the following possible ? std::string str; std::basic_string_view sv = str; Would that be an Ok customization ?
darune's user avatar
  • 11.5k
361 votes
21 answers
46k views

I often hear that when compiling C and C++ programs I should "always enable compiler warnings". Why is this necessary? How do I do that? Sometimes I also hear that I should "treat warnings as errors"...
n. m. could be an AI's user avatar
10 votes
1 answer
565 views

When using placement new in generic code to construct an object at a specified address, the usage pattern is a bit different from usual code. For example, consider this implementation of ...
L. F.'s user avatar
  • 21k
74 votes
5 answers
171k views

If I need to write a setter and/or getter for I write it like this: struct X { /*...*/}; class Foo { private: X x_; public: void set_x(X value) { x_ = value; } X get_x() ...
bolov's user avatar
  • 77.3k
496 votes
5 answers
240k views

Recently I've gotten suggestions to use span<T>'s in my code, or have seen some answers here on the site which use span's - supposedly some kind of container. But - I can't find anything like ...
einpoklum's user avatar
  • 140k
110 votes
3 answers
13k views

I have started learning C++ for my programming class. I have downloaded this "Hello World" program: #include <iostream> using namespace std; int main() { cout << "Hello, World!"; ...
n. m. could be an AI's user avatar

15 30 50 per page
1
2 3 4 5
12