Skip to main content
Stack Overflow
  1. About
  2. For Teams
Filter by
Sorted by
Tagged with
3 votes
1 answer
175 views

According to cppreference documentation, std::memmove and std::memcpy would expect an object address as input, which will theoretically limit there usage with buffer obtained from C-like API (mmap, ...
2 votes
3 answers
141 views

Consider this example: #include <atomic> #include <chrono> #include <thread> uint64_t timestamp() { auto now = std::chrono::steady_clock::now().time_since_epoch(); return ...
11 votes
1 answer
345 views

Clang compiles the following C++20 code snippet, while at the same time it is rejected by both GCC and MSVC. There are at least two options: The code is illegal and Clang fails to report an ...
4 votes
1 answer
162 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 ...
2 votes
1 answer
120 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 ...
-4 votes
0 answers
313 views

Consider this example: #include <atomic> #include <chrono> #include <thread> int main() { std::atomic<long int> key; auto t1 = std::thread([&]() { auto now =...
2 votes
0 answers
263 views
+50

Consider this example: #include <thread> #include <atomic> #include <stream> int main(){ std::ofstream outFile("example.txt", std::ios::out | std::ios::trunc); std::...
-1 votes
0 answers
136 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&...
15 votes
3 answers
436 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 ...
5 votes
1 answer
175 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 ...
5 votes
2 answers
258 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, ...
17 votes
1 answer
674 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 ...
1 vote
1 answer
188 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; } ...
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 ...
1 vote
0 answers
59 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

15 30 50 per page
1
2 3 4 5
...
599

AltStyle によって変換されたページ (->オリジナル) /