C++ Logo

STD-DISCUSSION

Advanced search

Subject: Re: Question about name lookup and class member?
From: Eric Suen (eric_suen_at_[hidden])
Date: 2021-06-08 07:04:08


> 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<>();
}


STD-DISCUSSION list run by std-discussion-owner@lists.isocpp.org

Older Archives on Google Groups