"using" declaration and template (generic) classes

K

Kevin Frey

Hello All,

I want to refer to the Nullable< T > template type in C++/CLI (a header
file) without requiring explicit qualification of the System:: namespace.

So I effectively want to do this (which won't actually compile):

using System::Nullable< T >; // or something to this affect

class MyClass
{
property Nullable< int > MyProperty
{
// ...
}
};

I can't find the right syntax to do this - yes I could use using namespace
System and yes I could qualify the typename (which I have done for the
moment as a workaround).

But it's now an academic exercise for me. Is it possible for a using
declaration to reference a generic class, and what is the syntax?

Nothing I have tried works, such as:

using System::Nullable< T >;
using System::Nullable< typename >;
using System::Nullable< typename T >;
template< typename T > using System::Nullable< T >;

And I can't find anything online or in the documentation.

Thanks

Kevin
 
C

Carl Daniel [VC++ MVP]

Kevin Frey said:
But it's now an academic exercise for me. Is it possible for a using
declaration to reference a generic class, and what is the syntax?

AFIAK, no, it's not possible - there's no syntax for using to bring an
un-specialized generic into scope.

-cd
 
B

Ben Voigt [C++ MVP]

Kevin Frey said:
Hello All,

I want to refer to the Nullable< T > template type in C++/CLI (a header
file) without requiring explicit qualification of the System:: namespace.

So I effectively want to do this (which won't actually compile):

using System::Nullable< T >; // or something to this affect

class MyClass
{
property Nullable< int > MyProperty
{
// ...
}
};

I can't find the right syntax to do this - yes I could use using namespace
System and yes I could qualify the typename (which I have done for the
moment as a workaround).

But it's now an academic exercise for me. Is it possible for a using
declaration to reference a generic class, and what is the syntax?

Nothing I have tried works, such as:

using System::Nullable< T >;
using System::Nullable< typename >;
using System::Nullable< typename T >;
template< typename T > using System::Nullable< T >;

And I can't find anything online or in the documentation.

Maybe typedef would work better.
Thanks

Kevin


__________ Information from ESET NOD32 Antivirus, version of virus
signature database 4590 (20091109) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com

__________ Information from ESET NOD32 Antivirus, version of virus signature database 4590 (20091109) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top