C++ cli 什么是C++;CLI相当于vb';什么都没有?

C++ cli 什么是C++;CLI相当于vb';什么都没有?,c++-cli,C++ Cli,我在这样一个地方 generic <typename ItemType> where ItemType : ItemBase public ref class Container { ItemType GetItem(int i) { ... if (someSpecialCondition) return ??? ... } }; generic其中ItemType:ItemBase 公共参考类容器{ ItemTyp

我在这样一个地方

generic <typename ItemType> where ItemType : ItemBase
public ref class Container {
    ItemType GetItem(int i) {
        ...
        if (someSpecialCondition) return ???
        ...
    }
};
generic其中ItemType:ItemBase
公共参考类容器{
ItemType GetItem(int i){
...
如果(某些特殊情况)返回???
...
}
};

我想返回与vb的“Nothing”等价的值,但无法理解它的语法。它不喜欢null或nullptr,我知道很多。

它对于泛型非常不直观,请注意,如果类型参数是值类,它不能是
nullptr
。它还与语言规范不匹配,该规范承诺当类型被约束为
ref class
时,nullptr是有效的

类型
T
的默认值为
T()
。因此:

ItemType GetItem(int i) {
    ...
    if (someSpecialCondition) return ItemType();
    ...
}
如果ItemType是引用类型,则生成nullptr;如果ItemType是值类型,则生成默认值(所有成员零初始化)。在VB.NET中,
什么都不做
做同样的事情