This is a follow up of Template class type alias failing substitution in member declaration
Consider this code:
// A
template <typename T>
struct foo {
using type = unsigned;
template <type x>
void bar(type (&)[x]);
};
template <typename T>
template <typename foo<T>::type x>
void foo<T>::bar(type (&)[x]){}
gcc emits the following error:
<source>:13:6: error: no declaration matches 'void foo<T>::bar(foo<T>::type (&)[x])'
13 | void foo<T>::bar(type (&)[x]){}
| ^~~~~~
<source>:8:10: note: candidate is: 'template<class T> template<unsigned int x> void foo<T>::bar(foo<T>::type (&)[x])'
8 | void bar(type (&)[x]);
| ^~~
<source>:4:8: note: 'struct foo<T>' defined here
4 | struct foo {
| ^~~
Compiler returned: 1
clang:
<source>:13:14: error: out-of-line definition of 'bar' does not match any declaration in 'foo<T>'
void foo<T>::bar(type (&)[x]){}
^~~
1 error generated.
Compiler returned: 1
When I remove what is identical in the erroneous definition and the candidate I get this:
// B
template <typename T>
struct foo {
using type = unsigned;
template <type x>
void bar();
};
template <typename T>
template <typename foo<T>::type x>
void foo<T>::bar(){}
This compiles fine (gcc / clang)
An attempt to answer the original question (by Darhuuk, slightly modified) was this:
// C
#include <type_traits>
template <typename T> struct length { using type = unsigned int; };
template <typename T> using length_t = typename length<T>::type;
template <typename type>
class Object {
template <length_t<Object<type>> length>
void put(type (&)[length]);
};
template <typename type>
template <length_t<Object<type>> length>
void Object<type>::put(type (&)[length]) {}
int main() {}
Clang seems to have similar problems as with the original code and emits the error:
<source>:15:20: error: out-of-line definition of 'put' does not match any declaration in 'Object<type>'
void Object<type>::put(type (&)[length]) {}
^~~
1 error generated.
while gcc compiles it without complaints.
Who is right about C
? Is it a bug in clang or is gcc being lax?
Why does A
not compile while B
does?
It was clear that further research was in order. Now, after years of intensive bar visitation, I have determined that there are precisely eight kinds of bar in the world. I call them the Barchetypes.
Public or front bars – The least expensive and basic type of hotel (or pub) bar is usually called the public bar or front bar. Lounge or saloon bars – These bars are more comfortably furnished (and more expensive) than the public bar. Foyer bars – Superior residential hotels often serve drinks in the foyer.
3. Wine Bar or Liquor Bar Cocktail Bar Beer Bar Public bar Lounge bar Sports Bar Night Club Bar Dive Bar Cabaret Bar 4. Wine bar sell everything from Beer to Hard Liquor. Wine Bars admit only adult customers. Traditionally modern wine bar combine wine with selections of appetizers.
We offer different sizes Bar Type TFT (Stretched Bar LCD Display) including sizes of 3.9 inch, 4.6 inch and 5.2 inch. In order to meet with customers requirement especially for industrial applications, we develop more derivative solution from these Bar type TFT as below:
They may not become your favorite bar or pub, but they certainly have the basics of what you’re looking for when you enter one of these establishments, which is alcohol. Specialty bars usually center around a certain drink, such as a martini bar, or even something else that is unique, such as cigar bars.
The bar chart allows a number of properties to be specified for each dataset. These are used to set display properties for a specific dataset. For example, the color of the bars is generally set this way.
as I mentioned in Template class type alias failing substitution in member declaration:
CWG2, the ancient issue that nobody knows when it's posted, is still drafting, which means the match rule of out-of-definition is even unspecified. these weird mismatches are because of the different implementations of compilers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With