GCC Bugzilla – Attachment 26045 Details for
Bug 51501
[DR 1433] decltype over-agressive SFINAE
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
test case
bug.cpp (text/plain), 1.44 KB, created by
Dave Abrahams
on 2011-12-10 21:06:14 UTC
(
hide
)
Description:
test case
Filename:
MIME Type:
Creator:
Dave Abrahams
Created:
2011-12-10 21:06:14 UTC
Size:
1.44 KB
patch
obsolete
>template <class T> T declval(); > >struct nil_ { constexpr nil_() {} }; >constexpr nil_ nil; > >template <class H, class T = nil_> >struct cons_ >{ > constexpr cons_() {} > constexpr cons_(H const& x, T const& y) : head(x), tail(y) {} > > H head; > T tail; >}; > >template <class H, class T> >constexpr cons_<H,T> cons(H const& h, T const& t) >{ return cons_<H,T>(h,t); } > > >#define RETURNS_CAT_0(x, y) x ## y >#define RETURNS_CAT(x, y) RETURNS_CAT_0(x,y) >#define RETURNS(...) -> decltype(__VA_ARGS__) { return (__VA_ARGS__); } typedef int RETURNS_CAT(RETURNS_, __LINE__) > >constexpr auto list() > RETURNS( nil ); > >template <class T> >constexpr auto list(T x) > RETURNS( cons(x, nil) ); > >#ifndef WORKAROUND >template <class H, class ...T> >constexpr auto list(H h, T ...args) > RETURNS(cons( h, list( args... ) )); >#else > >template <class... T> struct list_; > >template <class H, class... T> >struct list_<H,T...> >{ > using type = cons_<H,typename list_<T...>::type>; >}; >template <> struct list_<> >{ > using type = nil_; >}; > >// Used to prove we're calculating the type correctly >template <class T, class U> struct assert_same; >template <class T> struct assert_same<T,T>{}; > >template <class H, class ...T> >constexpr auto list(H h, T ...args) > -> typename list_<H,T...>::type >{ > return assert_same< > decltype(cons( h, list(args...) )), > typename list_<H,T...>::type > >(), > cons( h, list(args...) ); >} >#endif > >auto list3 = list(1, 2, 3); > >int main() {}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 51501
: 26045