Library exposing STL containers

B

Bob

Hi,

I'm writing an application using an API that's still under development. Most
data is communicated via std::map<> and so forth. Correct me if I'm wrong,
but isn't that a bad idea? If a function returns a container, could it
populate it using one implementation of STL while I try to retrieve it with
another, and potentially wreak havoc?

Bob
 
P

Pete Becker

Bob said:
I'm writing an application using an API that's still under development. Most
data is communicated via std::map<> and so forth. Correct me if I'm wrong,
but isn't that a bad idea? If a function returns a container, could it
populate it using one implementation of STL while I try to retrieve it with
another, and potentially wreak havoc?

Sure. And if you return an int, it could be populated with one
implementation of int and when you retrieve it with another, and
potentially wreak havoc. The solution in both cases is don't do that.
Use the same compiler for all parts of your application, and use its
standard library everywhere. That's why the standard library comes with
the compiler.
 
B

Bob

Pete Becker said:
Sure. And if you return an int, it could be populated with one
implementation of int and when you retrieve it with another, and
potentially wreak havoc. The solution in both cases is don't do that. Use
the same compiler for all parts of your application, and use its standard
library everywhere. That's why the standard library comes with the
compiler.

Well, for one, the API is in its own library and I have no control over it.
Second, STL is template code; can that really be shared code anyway?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top