Skip to main content
The 2026 Annual Developer Survey is live— take the Survey today!
Score of 9
1 answer
657 views

Assume there are two translation units that differ only in the name of one namespace: aggregator_1 vs. aggregator_2: // Translation unit 1 namespace a { struct Point { int x; int ...
Score of 4
1 answer
142 views

The one definition rule in the C++20 standard states that there can be no two definitions of a class type in a program unless the two definitions are in different translation units and have the same ...
Score of 5
2 answers
178 views

I'm writing a header-only library which defines class X in header x.hpp. The implementation of X is different for different standard versions: #if __cplusplus < 201703 class X { int a; ...
Score of 5
1 answer
177 views

In the C++20 draft (N4868) there are two relevant rules about definition reachability: Inline functions must have their definition reachable in every translation unit in which they are ODR-used: [...
Score of 4
2 answers
172 views

In The C++ Programming Language 4th edition, in §6.3, page 153, I read Any declaration that specifies a value is a definition Again, in §15.2, page 421, a declaration with an initializer is always ...
Score of 6
1 answer
126 views

I am writing a header file, in which there is a void Foo() function in file scope, and I want it to be deleted. Should it be inline? void Foo() = delete; or inline void Foo() = delete;
Score of 5
2 answers
336 views

I have the following code - template <typename T, typename F> struct unique {}; template <auto F> struct ltype { using type = decltype(F); }; using p = unique<int, ltype<[](){}&...
Score of 0
1 answer
266 views

Consider the following example: #include <iostream> using namespace std; int main() { int n=1; []() { n;// (1): error }...
Score of 14
4 answers
258 views

I have two classes that are independently declared in their own header and have their methods defined in their own TUs /.cpp's. the classes are the same name-wise and namespace-wise, but exist in ...
Score of 0
1 answer
84 views

I need to define a member function __say_hi on a class template, which will not be called anywhere, but still need to be kept by my clang-based frontend. To do so, I add a constexpr static member ...
Score of 0
0 answers
98 views

I have a hard problem with multiple definitions of symbols in a complicated environment I do not completely control. I apologise in advance for the verbosity of the question... but it's quite ...
Score of 2
0 answers
74 views

I'm working on a project, with CMake, that uses mainly two different libraries: ROOT: https://root.cern/ OpenCASCADE: https://dev.opencascade.org/ When I try compiling I get errors of ambiguity. ...
Score of 2
1 answer
138 views

C++23 says that constexpr functions and static data members are implicitly inline, but it does not say the same for namespace-scope constexpr variables. It also says that: "For any definable ...
Score of 1
1 answer
179 views

In old versions of C++, such as C++17, the one-definition rule was intuitive at a high-level in that it allowed only one definition of variables Every program shall contain exactly one definition of ...
Score of 3
1 answer
102 views

If a class template uses a lambda a default template argument, every default usage of that class type will be a new type. template <auto unique = [] {}> struct UniqueStruct {}; static_assert(!...

15 30 50 per page
1
2 3 4 5
23