由于C++没有内置的元组类型,我建议你看一下 Boost,这是一个非常全面、成熟且开源的库,几乎可以满足您在 C++ 中所需的任何内容。在 Boost 下,查看 Fusion 库,或者如果您需要不简单的东西,请访问Tuple 库。
编辑 正如 Matt 在下面提到的,从 TR1 开始,元组是 C++ 标准库的一部分。请参阅此处 Matt 的链接。
That's because 'cell' is not really a type - it is a placeholder for anything you want to place in it. The closest thing I can think of in languages such as C# and Python is a 'tuple', which intrinsically can contain anonymous types.
Since C++ does not have a built-in tuple type, I suggest you take a look at Boost, which is a very comprehensive, mature and open-source library for practically anything you need in C++. Under Boost, take a look at the Fusion library, or if you require something not simpler, at the Tuple library.
EDIT as Matt mensioned below, as of TR1, tuples are part of the C++ standard library. See Matt's link here.
您的单元格数据可能会很好地转换为 C++ 对象。我建议您检查单元格包含的内容,看看是否可以将其表示为一个类。然后,您将能够创建对象的向量/数组/矩阵,并像 MATLAB 中的单元格一样处理它们。
Your cell data will likely translate fairly well into a C++ object. I would recommend you examine what your cells contain and see if you could represent it as a class. Then you would be able to create vectors/arrays/matrices of your objects and have them treated similar to cells in MATLAB.
发布评论
评论(3)
这是因为“单元格”并不是真正的类型 - 它是您想要放入其中的任何内容的占位符。在 C# 和 Python 等语言中,我能想到的最接近的东西是“元组”,它本质上可以包含匿名类型。
由于C++没有内置的元组类型,我建议你看一下 Boost,这是一个非常全面、成熟且开源的库,几乎可以满足您在 C++ 中所需的任何内容。在 Boost 下,查看 Fusion 库,或者如果您需要不简单的东西,请访问Tuple 库。
编辑 正如 Matt 在下面提到的,从 TR1 开始,元组是 C++ 标准库的一部分。请参阅此处 Matt 的链接。
That's because 'cell' is not really a type - it is a placeholder for anything you want to place in it. The closest thing I can think of in languages such as C# and Python is a 'tuple', which intrinsically can contain anonymous types.
Since C++ does not have a built-in tuple type, I suggest you take a look at Boost, which is a very comprehensive, mature and open-source library for practically anything you need in C++. Under Boost, take a look at the Fusion library, or if you require something not simpler, at the Tuple library.
EDIT as Matt mensioned below, as of TR1, tuples are part of the C++ standard library. See Matt's link here.
犰狳有 field 类!
Armadillo has field class!
您的单元格数据可能会很好地转换为 C++ 对象。我建议您检查单元格包含的内容,看看是否可以将其表示为一个类。然后,您将能够创建对象的向量/数组/矩阵,并像 MATLAB 中的单元格一样处理它们。
Your cell data will likely translate fairly well into a C++ object. I would recommend you examine what your cells contain and see if you could represent it as a class. Then you would be able to create vectors/arrays/matrices of your objects and have them treated similar to cells in MATLAB.