I'm having serious trouble getting the standard library to work in a c++.net DLL. I can't use the one here because speed is a priority in my
application. But any time I use #include , my code won't compile. I get errors like:
"wasteoftime error LNK2020: unresolved token (0A000006) _CxxThrowException"
"wasteoftime error LNK2020: unresolved token (0A000016) delete".
As a test I even started a new class library project, and pasted every bit of code from the download here into mine, and still got the same problem. (the original compiles fine)
And make it simple please. I'm not a Programmer by trade. I'm just a Physicist.
First of all, it's managed C++. This could be written entirely using straight C#.
Secondly, why are you using std::complex?. You're instantiated the template using a double in the C++ section, so the C# and VB side doesn't benefit from the point of a template, which is to instantiate whatever type you want. Therefore, this supports the previous point that this should have been written in C# to begin with.
BTW, C++ doesn't inherently support complex types (last time I checked). This is provided by STL.
You might want to look at this link for some simplistic examples:
As this article discusses, you might also want to overload the equality operators so we can compare complex numbers.
Finally, as you say, there's a major performance hit using complex numbers with managed C++. If I were writing a complicated math function with lots of complex number calculations, I really wouldn't want to incur these performance hits.
Thanks for the comment.
You are right it could be in straight C# and that would be nice.
My goal was full functionality, which is where managed C++ is great. C# and VB get to use the STL indirectly to get full functionality. The tradeoff is losing some flexibility and performance in non trivial cases. For the easy cases I am NOT using STL!
I use STL to handle non-trivial cases letting it worry about significant bits, as needed. With time more functions could be converted away from the STL wrapper. At that point it would be an easy port to C# if desired.
I HAVE overloaded the equality and other operators. I was hoping for feedback on why I needed to create redundant functions like Equals() to make it work in VB. The overloaded stuff works great in C++ and C#, but not everything maps to VB.
Ok STL is not “built” into the language but any good C++ compiler has STL, hence you can do complex math with C++ and FORTRAN.