re PR c++/68388 (incomplete type bug when using decltype)
2015-11-24 Paolo Carlini <paolo.carlini@oracle.com> PR c++/68388 * g++.dg/cpp1y/pr68388.C: New. From-SVN: r230827
This commit is contained in:
parent
ff17c26257
commit
660f3dc7dd
@ -1,3 +1,8 @@
|
||||
2015-11-24 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
PR c++/68388
|
||||
* g++.dg/cpp1y/pr68388.C: New.
|
||||
|
||||
2015-11-24 Aditya Kumar <aditya.k7@samsung.com>
|
||||
Sebastian Pop <s.pop@samsung.com>
|
||||
|
||||
|
42
gcc/testsuite/g++.dg/cpp1y/pr68388.C
Normal file
42
gcc/testsuite/g++.dg/cpp1y/pr68388.C
Normal file
@ -0,0 +1,42 @@
|
||||
// { dg-do compile { target c++14 } }
|
||||
|
||||
namespace std {
|
||||
typedef int size_t;
|
||||
template <std::size_t... Indexes>
|
||||
struct index_sequence {};
|
||||
}
|
||||
|
||||
template <class...> class Tuple {};
|
||||
|
||||
template <std::size_t I, class TFirst>
|
||||
auto get(Tuple<TFirst>) {
|
||||
return TFirst();
|
||||
}
|
||||
|
||||
template <std::size_t I, class Functor, class T1, class T2>
|
||||
auto apply_impl(Functor f, T1 t1, T2 t2) {
|
||||
return f(get<I>(t1), get<I>(t2));
|
||||
}
|
||||
|
||||
template <std::size_t... Indexes, class Functor, class T1, class T2>
|
||||
auto map_impl(std::index_sequence<Indexes...>, Functor f, T1 t1, T2 t2) {
|
||||
Tuple<decltype(apply_impl<Indexes>(f, t1, t2))...>();
|
||||
}
|
||||
|
||||
template <class Functor, class T1, class T2>
|
||||
auto map_impl(Functor f, T1 t1, T2 t2) {
|
||||
map_impl(std::index_sequence<0>(), f, t1, t2);
|
||||
}
|
||||
|
||||
struct Less {
|
||||
template <class Lhs, class Rhs>
|
||||
auto operator()(Lhs lhs, Rhs rhs) -> decltype(lhs < rhs) {
|
||||
return lhs < rhs;
|
||||
}
|
||||
};
|
||||
|
||||
int main() {
|
||||
auto t1 = Tuple<int>();
|
||||
auto t2 = Tuple<int>();
|
||||
map_impl(Less(), t1, t2);
|
||||
}
|
Loading…
Reference in New Issue
Block a user