decltype and std::integral_constant

2010-04-01 Thread pmenso57
The following translation unit seems to show a bug exhibited by 4.4.3 and 4.5. 

#include  

template struct plus 
: std::integral_constant< 
decltype(X::value + Y::value), 
X::value + Y::value 
> { }; 

int main(int argc, char* argv[]) { 
return 0; 
} 

Compiling this file (test.cpp) with 

g++ -std=c++0x -l stdc++ test.cpp 

yields the following diagnostic: 

test.cpp:7: error: 'decltype ((X::value + Y::value))' 
is not a valid type for a template constant parameter 

Am I missing something? The following works as intended: 

#include  
#include  

template struct plus 
: std::integral_constant< 
typename std::identity::type, 
X::value + Y::value 
> { }; 

int main(int argc, char* argv[]) { 
return 0; 
} 

(i.e. just wrapping the use of decltype with std::identity) 

Regards, 
Paul Mensonides 


[Bug c++/54890] New: Incorrect SFINAE Rejection

2012-10-10 Thread pmenso57 at comcast dot net

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54890

 Bug #: 54890
   Summary: Incorrect SFINAE Rejection
Classification: Unclassified
   Product: gcc
   Version: 4.7.2
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: pmens...@comcast.net


When explicitly specifying the template parameters to a function template in
the following context, the compiler incorrectly removes the function from the
overload set for a substitution failure which should not exist.

struct A {
template struct apply { };
};

template
void f(typename T::template apply*) { }

int main() {
f(nullptr);
return 0;
}

Output from the compiler is:

In function ‘int main()’:
error: no matching function for call to ‘f(std::nullptr_t)’
note: candidate is:
note: template void f(typename T::apply*)
note:   template argument deduction/substitution failed:
note:   mismatched types ‘A::apply*’ and ‘std::nullptr_t’

Which I believe is incorrect.