Doc*_*own 27 .net c# type-inference c++-cli
在C#中,我喜欢这样的var
情况下的关键字:
var myList = new List<MyType>();
Run Code Online (Sandbox Code Playgroud)
在C++/CLI中是否有任何等价物,或者每次都必须重复类型名称,如下所示:
List<MyType ^>^ myList = gcnew List<MyType ^>();
Run Code Online (Sandbox Code Playgroud)
到目前为止,无法在文档或Google中找到明确的声明.我正在使用Visual Studio 2008.
Jar*_*Par 37
在Visual Studio 2008中没有这样的等价物.但是,使用Visual Studio 2010,您可以使用auto
关键字var
在C++中实现类似语义.我知道这适用于非托管C++,我相当肯定它也适用于C++/CLI.
Max*_*kin 12
我知道在C++ 1x标准中设想了类型推断:
auto someStrangeCallableType = boost::bind(&SomeFunction, _2, _1, someObject);
auto otherVariable = 5;
Run Code Online (Sandbox Code Playgroud)
目前,AFAIK,没有相应的.