www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript

c++ - cannot find constructor

↑ ↓ ← Christof Meerwald <cmeerw web.de> writes:
struct A
{
  A(int)
  { }
};

template<class T>
struct B
{
  T t;
  // Error: cannot find constructor for class matching A::A()
};

int main()
{
  B<A> *a = 0;
  B<A> b(*a);

  return 0;
}


There is no need trying to instantiate the default constructor for B<A>.
From Boosts regex++ library (low priority).


bye, Christof

-- 
http://cmeerw.org                                 JID: cmeerw jabber.at
mailto cmeerw at web.de

...and what have you contributed to the Net?
Jan 02 2003
↑ ↓ "Walter" <walter digitalmars.com> writes:
I'm mystified how this can work. How can any instance of B<A> be created?

"Christof Meerwald" <cmeerw web.de> wrote in message
news:av264i$ub6$2 digitaldaemon.com...
 struct A
 {
   A(int)
   { }
 };

 template<class T>
 struct B
 {
   T t;
   // Error: cannot find constructor for class matching A::A()
 };

 int main()
 {
   B<A> *a = 0;
   B<A> b(*a);

   return 0;
 }


 There is no need trying to instantiate the default constructor for B<A>.
 From Boosts regex++ library (low priority).


 bye, Christof

 --
 http://cmeerw.org                                 JID: cmeerw jabber.at
 mailto cmeerw at web.de

 ...and what have you contributed to the Net?

Jan 04 2003
↑ ↓ Christof Meerwald <cmeerw web.de> writes:
On Sat, 4 Jan 2003 01:35:12 -0800, Walter wrote:
 I'm mystified how this can work. How can any instance of B<A> be created?

STLport does it this way: A a(0); B<A> *b1 = (B<A> *) malloc(sizeof(B<A>)); new (&b1->t) A(a);
 "Christof Meerwald" <cmeerw web.de> wrote in message
 news:av264i$ub6$2 digitaldaemon.com...
 struct A
 {
   A(int)
   { }
 };

 template<class T>
 struct B
 {
   T t;
   // Error: cannot find constructor for class matching A::A()
 };


bye, Christof -- http://cmeerw.org JID: cmeerw jabber.at mailto cmeerw at web.de ...and what have you contributed to the Net?
Jan 04 2003
↑ ↓ → "Walter" <walter digitalmars.com> writes:
That's working around how C++ is supposed to work. Object instances are only
supposed to be built with constructors. Of course, STLport can be easilly
fixed by adding the missing constructor. The malloc call below should be
replaced with a new().

"Christof Meerwald" <cmeerw web.de> wrote in message
news:av6jqo$eoo$1 digitaldaemon.com...
 On Sat, 4 Jan 2003 01:35:12 -0800, Walter wrote:
 I'm mystified how this can work. How can any instance of B<A> be


 STLport does it this way:

   A a(0);

   B<A> *b1 = (B<A> *) malloc(sizeof(B<A>));
   new (&b1->t) A(a);


 "Christof Meerwald" <cmeerw web.de> wrote in message
 news:av264i$ub6$2 digitaldaemon.com...
 struct A
 {
   A(int)
   { }
 };

 template<class T>
 struct B
 {
   T t;
   // Error: cannot find constructor for class matching A::A()
 };


bye, Christof -- http://cmeerw.org JID: cmeerw jabber.at mailto cmeerw at web.de ...and what have you contributed to the Net?

Jan 04 2003