Sign in to follow this  

Forward declaration of an STL class (wstring)?

This topic is 3310 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is there a way to do this. i have a c++ class I am placing in a win32 dll it uses wstrings in some of its function prototypes for parameters, no returns. I want to then wrap this in a C++ CLR Class Lib but i want this class to have as little reference to STL as possible ie none if possible :p, and to that end don't want to include the <string> header in my win32 dll c++ header. I'm assuming this should be fine because a wstring can accept a terminated char array on construction which is what the calling class will pass. So in short is there a way to provide a forward declaration of wstring without including <string>. I am going to use wchar_t* in the mean time but i am curious now.

Share this post


Link to post
Share on other sites
ah, ya was thinking it was because it was a template class, and that it would not be simple.

I really need to get round to learning templates some time :$, so much else to learn though

I am just going to go with char array. Wasn't doing any string operations anyway.

Share this post


Link to post
Share on other sites
Quote:
Original post by swiftcoder
Because std::wstring is actaully a typedef of a template instantiation (typedef std::basic_string<wchar_t> wstring;), it is quite difficult to provide a forward declaration - as with any template class.


The C++ standard forbids forward declarations of pretty much anything in the std namespace :(

I think the reason being that implementations are free to add additional arguments with default arguments and similarly for template parameters.

The only concession is the <iosfwd> header for streams.

Share this post


Link to post
Share on other sites

This topic is 3310 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this