STD Classes in CUDA

I know that we can’t use native STD Classes in CUDA. However, when developing cuda code, they became necessary (strings and vectors at least.) I searched the problem in internet for a long time but couldn’t find the solution. I can’t believe there isn’t one. Do all of you code without such classes? As I couldn’t find the solution, I started to write my own string class and thought to define all functions “host device” So, that I could use it in host and device code. (This was necessary, because I needed string class as variable in another class which I could use in both host and device code - I tried to write such thing but it didn’t work:

Class fooclass{

public:

#ifdef __CUDA_ARCH__

 mynamespace::string foostr;

#else

 std::string foostr;

#endif

};

)

Now, back to the topic. When I defined functions with “host device” - this, compiler returned error of multiple definitions. I googled the problem and found http://choorucode.wordpress.com/2011/03/14/cuda-common-function-for-both-host-and-device-code/ (the last code in the link is solution to my problem) this solution. However, I don’t like it, because I want to have string.cu and string.cuh files separately, and host and kernel code also in different files. In this link, author states that kernel code must be in the same file where is declaration of function.

Isn’t there any solution? btw, I have GTX 580, so there is no problem in calling malloc() from kernel. I mean, I can do everything if I define the function in only device. However, I want to use it in another class and I want to use that class on both CPU and GPU which is impossible, because that class will have string with only device functions :(

The only way I could do was not to define functions in separate .h file. So, now I use one .cpp file in which I have declaration of whole class. If someone has found another solution, please write down. Also, in VS2010 I had to change “Project Properties -> Configuration Properties -> C/C++ -> Code Generation -> Runtime Library” from /Mt to /Md.