I've been having a lot of trouble making an array that is accessible to all the functions in my class in C++/CLI. Since it's C++/CLI, std::vector doesn't work. Boost::array throws an error about unmanaged types being used with managed types. I don't want to use a pointer array because I want to get the size of the array. System::List is too slow (every ms matters in my program, but if it helps, I don't care about write speeds to the array, only read speeds of one element at a time). cliext::vector was the closest I got to getting this to work.
I created a single dimensional cliext::vector with an int, and it worked. However, when I tried to use
cliext::vector<cliext::vector<int>> test;
it failed with a similar error as the one below. Here is how I used it in my class:
The header:
cliext::vector<Color> test;
I set values for it in the constructor:
test = gcnew cliext::vector<Color>(5);
test[0] = Color(255,255,255);
I then tried to make a class that would store 3 variable for color. Here is the header file. The constructor just sets the r,g,b values:
namespace FrameCalculator {
class Color {
public:
Color(int r, int g, int b);
int r;
int g;
int b;
};
However this didn't work, and it threw the error below:
1>E:\Microsoft Visual
Studio\2017\Community\VC\Tools\MSVC\14.11.25503\include\cliext\vector(1091):
note: see reference to class template instantiation
'cliext::impl::vector_base<_Value_t,false>' being compiled
1> with
1> [
1> _Value_t=FrameCalculator::Color
1> ]`
and
1>E:\Microsoft Visual
Studio\2017\Community\VC\Tools\MSVC\14.11.25503\include\cliext\vector(615):
error C3671: 'cliext::impl::vector_impl<_Value_t,false>::SyncRoot::get':
function does not override 'System::Collections::ICollection::SyncRoot::get'
1> with
1> [
1> _Value_t=FrameCalculator::Color
1> ]`
There were about 5 of each of these errors. What am I doing wrong? How do I get a 2d array that's not slow, is globally accessible. I don't need both arrays to be dynamic (I'd prefer them not to). I know the inner array will have 3 elements, but I won't know the outer array size at compile time. How do I achieve this?