www.digitalmars.com         C & C++   DMDScript  

c++ - Problem with templates at link time

Hello folks,

DMC (latest) seems unable to compile the code below.

The output is:

dmc -I\dm\stlport\stlport test.cpp
link test,,,user32+kernel32/noi;
OPTLINK (R) for Win32  Release 8.00.1
Copyright (C) Digital Mars 1989-2004  All rights reserved.
test.obj(test)
 Error 42: Symbol Undefined ?_M_copy ?$_Rb_tree std PAH0U?
$_Identity std PAH 1 U?$less std PAH 1 V?
$allocator std PAH 1  std  AAEPAU?$_Rb_tree_node std PAH 2 PAU32 0 Z
test.obj(test)
 Error 42: Symbol Undefined ?_M_erase ?$_Rb_tree std PAH0U?
$_Identity std PAH 1 U?$less std PAH 1 V?
$allocator std PAH 1  std  AAEXPAU?$_Rb_tree_node std PAH 2  Z
test.obj(test)
 Error 42: Symbol Undefined ?insert_unique ?$_Rb_tree std PAH0U?
$_Identity std PAH 1 U?$less std PAH 1 V?
$allocator std PAH 1  std  QAE?AU?$pair std U?
$_Rb_tree_iterator std PAHU?
$_Nonconst_traits std PAH 1  1 _N 2 ABQAH Z

Adding the -XD option doesn't help.

However, it compiles when moving the "Container<int>::insert" method
call in the main block (see commented line in main block).

Any ideas ?

Regards,

Cedric P.


--- cut ---
#include <set>

template<class T>
class Container
{
  public:
	typedef std::set<T*> SetType;

	static SetType getSet()
	{
	   static SetType mySet;
	   return mySet;
	}

	static int insert( T *x )
	{
	    getSet().insert(x);
	    return 0;
	}

};

const static int x = Container<int>::insert( new int(1) );

int main()
{
  //Container<int>::insert( new int(2) );
}
--- cut ---
Jun 30 2009