Library exposing STL containers

Discussion in 'C++' started by Bob, Jul 26, 2006.

  1. Bob

    Bob Guest

    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
     
    Bob, Jul 26, 2006
    #1
    1. Advertising

  2. Bob

    Pete Becker Guest

    Bob wrote:
    >
    > 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.
     
    Pete Becker, Jul 26, 2006
    #2
    1. Advertising

  3. Bob

    Bob Guest

    "Pete Becker" <> wrote in message
    news:...
    > 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?
     
    Bob, Jul 26, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Koen
    Replies:
    1
    Views:
    518
  2. Replies:
    7
    Views:
    579
    Pete Becker
    Jan 25, 2008
  3. Andrey Vul
    Replies:
    6
    Views:
    591
    James Kanze
    Oct 22, 2009
  4. jacob navia

    C Containers Library vs STL

    jacob navia, Aug 3, 2011, in forum: C++
    Replies:
    14
    Views:
    592
    Nobody
    Aug 4, 2011
  5. Sebastian Mach
    Replies:
    5
    Views:
    342
Loading...

Share This Page