C++ Logo

std-discussion

Advanced search

Re: Question about name lookup and class member?

From: Eric Suen <eric_suen_at_[hidden]>
Date: Tue, 8 Jun 2021 20:04:08 +0800
> If the default template argument is never used,

Except that is not the case here

std::cout << A().test<1>();
std::cout << A().test<>();

anyway, guess the spec is too complicated that no one can get it right,
just change the code a bit, gcc and msvc able to compile but clang failed.

#include <iostream>

struct A {
   int a = 1 + F<1>();

   template<int V>
   static constexpr int F(int a=H<>()) {
     return V;
   }

   template<int V = 1 + F<1>(0)>
   int test() {
     return V;
   }

   template<typename T=int, int V=1>
   static T H() {
     return V;
   }
};

int main() {
   std::cout << A().a;
   std::cout << A().test<1>();
   std::cout << A().test<>();
}

Received on 2021-06-08 07:04:21