According to The Rust Reference, If a main function is present, (snip), and its return type must be one of the following: () Result<(), E> where E: Erro
struct A { A(); A(int) = delete; operator int(); }; int main() { true ? A{} : 0; } Compile with C++20, Clang accepts it, but GCC and MSVC reject it w
The C++20 standard states the following about source file inclusion: 15.3:5 (page 437): The implementation shall provide unique mappings for sequences consisti
#include<type_traits> template <typename T, T> struct A { }; template <typename T, T t> void f(A<T, t>) { } int main() { f(A<c
C2x, 6.5.3.2 Address and indirection operators, Constraints, 2: The operand of the unary * operator shall have pointer type. Why there is no constraint "the o
C11, 6.7.2.1 Structure and union specifiers, Constraints, 3 (emphasis added): A structure or union shall not contain a member with incomplete or function type
The C (C99+) standard requires (though implicitly) a conforming implementation to define __STDC__ to 1. However, the C standard does not require an IEC 60559 co
Consider the following simple (to the extent that template questions ever are) example: #include <iostream> template <typename T> struct identity;
In C++11 or higher regardless of compiler int myArray[10] = { 0 }; would initialize to all elements to zero. The question is would this also work in C++98 and c
A widely used piece of code sets the default datefmt in logging.Formatter to "%a %b %d %H:%M:%S %Y %Z" (same as "%c" in C locale). The code was written 12+ year
For POD structure, could new Demo_Class[CONST_NUMBER]() guarantee the dynamically allocated structures are well initialised(i.e. not garbage) in C++11 and after
It's follow-up question to: How to detect non IEEE-754 float, and how to use them? In theory, can we assume that c float always support negative numbers?
Can someone please explain whether i = x[i]++; lead to undefined behavior? Note: x[i] and i are not both volatile and x[i] does not overlap i. There is C11, 6.5
All students are surprised by the behavior of C++ using-directives. Consider this snippet (Godbolt): namespace NA { int foo(Zoo::Lion); } namespace NB {
This is a followup on the answers for placement new on a class with reference field. Calling std::vector<A>::data() on type A that has reference or const
According to C99 Standard: The order of evaluation of the function designator, the actual arguments, and subexpressions within the actual arguments is unspe
In the following program, struct B has two user-defined constructors: one from int and another from int&& (clearly this is not very practical). And an o
Consider the following code snippet where we we're trying to deduce the template parameter to the function foobar(): struct Bar { static constexpr auto size =
Is the following code legal according to the standard? #include <new> int main() { const int x = 3; new ((void *)&x) int { 1
In reading How are char arrays / strings stored in binary files (C/C++)?, I was thinking about the various ways in which the raw string involved, "Nancy", would