This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/45114] implement C++0x alias-declaration
- From: "vincenzo.innocente at cern dot ch" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 31 Oct 2011 16:06:41 +0000
- Subject: [Bug c++/45114] implement C++0x alias-declaration
- Auto-submitted: auto-generated
- References: <bug-45114-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45114
--- Comment #10 from vincenzo Innocente <vincenzo.innocente at cern dot ch> 2011-10-31 16:06:41 UTC ---
using the patch of comment 8
in the example below I get
$ c++ -std=gnu++0x -c talias.cc
$ c++ -std=gnu++0x -c talias.cc -DALIAS
talias.cc: In instantiation of âBar::D<T> Bar::d() [with T = int]â:
talias.cc:44:19: required from here
talias.cc:34:23: error: no matching function for call to
âBar::D<int>::D(Bar::A<int>)â
talias.cc:34:23: note: candidates are:
talias.cc:19:5: note: Bar::D<T>::D(const Bar::A<T>&) [with T = int; Bar::A<T> =
Foo<int>]
talias.cc:19:5: note: no known conversion for argument 1 from âBar::A<int>
{aka Foo<int>}â to âBar::A<int>& {aka Foo<int>&}â
talias.cc:15:5: note: Bar::D<T>::D() [with T = int]
talias.cc:15:5: note: candidate expects 0 arguments, 1 provided
talias.cc:14:10: note: constexpr Bar::D<int>::D(const Bar::D<int>&)
talias.cc:14:10: note: no known conversion for argument 1 from âBar::A<int>
{aka Foo<int>}â to âconst Bar::D<int>&â
talias.cc:14:10: note: constexpr Bar::D<int>::D(Bar::D<int>&&)
talias.cc:14:10: note: no known conversion for argument 1 from âBar::A<int>
{aka Foo<int>}â to âBar::D<int>&&â
otherwise the patch looks fine (i.e. no other problem found so far :-)
template<typename T>
struct Foo {
explicit Foo(char *im) : m(im){}
char * m;
};
struct Bar {
template<typename T> using A = Foo<T>;
template<typename T>
struct D {
D() {}
#ifndef ALIAS
D(Foo<T> const & ia) : a(ia) {}
#else
D(A<T> const & ia) : a(ia) {}
#endif
A<T> a;
};
template<typename T>
A<T>
a() {
return A<T>(m_i);
}
template<typename T>
D<T> d() {
return D<T>(a<T>());
}
char m_i[10000];
};
Bar b;
Bar::D<int> bar() {
return b.d<int>();
}