.net - Incompatibility using managed array and std:array at same time -
i have c++/cli code using arrays (for example):
array<string^>^ getcolnames() { vector<string> vec = impl->getcolnames(); array<string^>^ arr = gcnew array<string^>(vec.size()); (int = 0; < vec.size(); i++) { arr[i] = strconvert(vec[i]); } return arr; }
it's compiling fine until add library "array" project:
#include <array>
then don't know how use managed cli array, because compiler thinks declared arrays std::array
.
errors examples:
array<string^>^ arr // ^ error here: "too few arguments class template "std::array"" gcnew array<string^>(vec.size()) // ^ error: "expected type specifier"
how solve this? tried removing using namespace std
file, makes no difference. should remove every other c++ file on project?
clearly have using namespace std;
in scope somewhere. watch out being used in .h file if cannot find it.
you can resolve ambiguity, c++/cli extension keywords array in cli
namespace. compiles fine:
#include "stdafx.h" #include <array> using namespace std; // <=== uh-oh using namespace system; int main(cli::array<system::string ^> ^args) { auto arr = gcnew cli::array<string^>(42); return 0; }
Comments
Post a Comment