Skip to main content
1 vote
1 answer
79 views

Furthermore, is the sizeof guaranteed to be the same on compatible types? I expect the answer to both of these questions is likely "yes" in practice, but I don't see anything in the standard ...
Grant Jurgensen's user avatar
2 votes
1 answer
98 views

Short version: Does an explicit instantiation declaration guarantee that a visible template definition is never used (unless an explicit instantiation definition is also encountered), and therefore ...
Bernard's user avatar
  • 5,820
0 votes
0 answers
134 views

Consider this example: #include <atomic> #include <chrono> #include <thread> int main() { std::atomic<long int> key; auto t1 = std::thread([&]() { auto now =...
xmh0511's user avatar
  • 7,675
1 vote
0 answers
183 views

Consider this example: #include <thread> #include <atomic> #include <stream> int main(){ std::ofstream outFile("example.txt", std::ios::out | std::ios::trunc); std::...
xmh0511's user avatar
  • 7,675
-1 votes
0 answers
135 views

Consider this example: #include <thread> #include <atomic> extern char* mysql_query(MYSQL* mysql,char const*); extern char* do_mysql_update(MYSQL* mysql); int main(){ std::atomic<bool&...
xmh0511's user avatar
  • 7,675
15 votes
3 answers
411 views

Often, I'd like to chain preprocessor conditionals involving __has_include (defined in C++17 and C23, and supported in earlier versions as an extension by many compilers (GCC 4.9.2 and up, and Clang ...
Noam Elul's user avatar
  • 854
5 votes
1 answer
171 views

I am work a mature codebase, one of the signs of its age is lack of consts which make the code difficult to reason about when refactoring. I have found a function which takes an argument as a mutable ...
Dominik Kaszewski's user avatar
5 votes
2 answers
247 views

std::to_chars has these two declarations: to_chars_result to_chars(char* first, char* last, floating-point-type value); to_chars_result to_chars(char* first, char* last, ...
Jan Schultke's user avatar
  • 44.5k
17 votes
1 answer
648 views

Consider struct A; namespace ns { int f(A&&); } struct A { friend int ns::f(A&&); }; int x = f(A{}); GCC trunk translates the last line into a call to ns::f(A&&) in C++20 ...
cpplearner's user avatar
  • 19.9k
1 vote
1 answer
184 views

What determines the order of initialization of static variables in class templates? Consider for example the program as follows: #include <iostream> int f() { static int s = 0; return ++s; } ...
Fedor's user avatar
  • 24.9k
22 votes
1 answer
1k views

GCC 15.2 (and many older versions) accepts the following code, while Clang 21.1 (and many older versions) don't: struct Wrapper { explicit Wrapper(int) {} }; template <int N = 0> struct ...
Benjamin Bihler's user avatar
1 vote
0 answers
58 views

According to cppreference, it is allowed to define an unscoped enum value by using prior values of the same enum, e.g. like this: enum MyEnum_U { u_foo = 2, u_bar = 5, u_baz = u_foo + ...
Thibe's user avatar
  • 758
9 votes
1 answer
186 views

[charconv.to.chars] says the following: The functions that take a floating-point value but not a precision parameter ensure that the string representation consists of the smallest number of ...
Jan Schultke's user avatar
  • 44.5k
22 votes
1 answer
746 views

Running the following code: #include <array> #include <iostream> using namespace std; array<int, 2> a; array<int, 2>& f() { cout << "f" << endl;...
Error-42's user avatar
  • 203
1 vote
1 answer
253 views

Consider this example: #include <atomic> #include <iostream> #include <thread> std::atomic<int> canceller = {0}; int main() { auto t1 = std::thread([]() { auto v = ...
xmh0511's user avatar
  • 7,675

15 30 50 per page
1
2 3 4 5
599