Skip to main content
6 votes
1 answer
146 views

A question to C++ standard lawyers. My feeling is that the following code should be 100% accepted, but GCC (all versions supporting C++23 including trunk) rejects constructs using trailing return type ...
Michał Staromiejski's user avatar
7 votes
1 answer
165 views

This code produces a compiler error in GCC, Clang, and MSVC (this is a heavily reduced test case for some real code that actually does something useful): #include <cstdint> #include <concepts&...
TartanLlama's user avatar
  • 66.3k
2 votes
0 answers
100 views

There seems to be a lot of confusion out there about if constexpr and the difference between dependent- and non-dependent expressions, particularly in the context of static_assert. Before CWG2518, ...
leekillough's user avatar
  • 1,117
1 vote
0 answers
77 views

Consider this example to illustrate that a nested type needs to be looked up via a dependent name, otherwise there'll be errors: template <typename T> struct base { struct inner{}; }; ...
463035818_is_not_an_ai's user avatar
3 votes
1 answer
156 views

To use a name from dependent base class in derived class template (e.g. B<T>), one has to add a prefix highlighting to the compiler that is a dependent name (B<T>::). And to avoid doing it ...
Fedor's user avatar
  • 25.7k
1 vote
1 answer
80 views

I had a checker function that used the requires keyword to detect if a target function was defined or not. I wanted to make it work with C++17, so I switched the checker from using requires to using ...
Joshua Maiche's user avatar
10 votes
1 answer
3k views

Considering the following code example, I would expect to have to use the template keyword here to guide the compiler to treat variable v as a template. However, MSVC rejects the use of the template ...
303's user avatar
  • 4,882
3 votes
1 answer
756 views

The following code doesn't work if class some_class is templated. So my guess is that I have to put the template specifier in front of something, but I don't really know where? I tried putting it in ...
glades's user avatar
  • 5,472
3 votes
0 answers
170 views

Premise: g++ and clang++ are known to be sometime discordant or not compliant on applying the rules for template disambiguation for dependent names. In this regard, the following code compiles under g+...
JtTest's user avatar
  • 381
5 votes
1 answer
3k views

Here is a simple code that MSVC 2022 compiles in C++17 mode, but fails in C++20 mode: template <typename T> void foo() { std::basic_string<T>::size_type bar_size; //This fails to ...
Regus Pregus's user avatar
0 votes
1 answer
206 views

We have a template member function of the form: template <template <class> class TT> TT<some_type> foo() const; Now, in an invocation context where TT is explicitly specified from a ...
Ad N's user avatar
  • 8,556
2 votes
1 answer
67 views

This program does not compile (error: 'foo' is not a member of 'N'): namespace N { // void foo(); } template<class T> void template_func(T t) { N::foo(t); } But if we uncomment the ...
Dr. Gut's user avatar
  • 3,607
0 votes
2 answers
171 views

I have written this code to understand template name lookup: //void bar(int); template <typename T> void foo(T x) { bar(x); } void bar(int x) { std::cout << "bar(int)\n"...
Maestro's user avatar
  • 2,573
4 votes
1 answer
89 views

Here's what the standard says about non-dependent names in a template definition: Non-dependent names used in a template definition are found using the usual name lookup and bound at the point they ...
cigien's user avatar
  • 61.3k
1 vote
0 answers
46 views

In C++ Primer 5th edition Chapter16 on templates: "It is up to the provider of a template to ensure that all names that do not depend on a template parameter are visible when the template is used....
Maestro's user avatar
  • 2,573

15 30 50 per page
1
2 3 4 5