BUG: C2512 Instantiating Template in Member InitializerLast reviewed: March 18, 1998Article ID: Q171064 |
The information in this article applies to:
SYMPTOMSWhen a member initializer instantiates a template class that takes a const parameter in its constructor, you may receive the following error:
error C2512: no appropriate default constructor available RESOLUTIONDeclare a global object of the template class specialization that is used in the member initializer. When optimizations are used, this unreferenced global should be optimized away.
STATUSMicrosoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available.
MORE INFORMATIONThis is a regression from Visual C++ 5.0.
Sample Code
// Compile options needed: none struct _Tree { _Tree(const int& _Parg) {} }; template<class _Pr> struct set { _Tree _Tr; set(const _Pr& _Pred = _Pr()) : _Tr(_Pred) {} }; struct Foo { Foo(); set<int>& _xSet; }; //set<int> x; // uncomment for workaround Foo::Foo() : _xSet(*new set<int>) //C2512 here {} |
Additional query words: visual studio service pack
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |