M
massysett
Greetings,
Having classes with member objects that have STL containers of objects
whose definitions are incomplete results in undefined behavior. See
for example:
http://www.ddj.com/database/184403814#8
http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.14
I am wondering: is it okay to have member functions that return an STL
container with an incomplete type? My member objects do not contain
incomplete types. For instance, would the following code be OK?
Thanks. --Omari
#include <boost/shared_ptr.hpp>
#include <vector>
class HasSelf
{
public:
HasSelf(std::vector<HasSelf>& contents);
std::vector<HasSelf> getContents() const;
private:
std::vector<boost::shared_ptr<HasSelf> > _contents;
};
Having classes with member objects that have STL containers of objects
whose definitions are incomplete results in undefined behavior. See
for example:
http://www.ddj.com/database/184403814#8
http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.14
I am wondering: is it okay to have member functions that return an STL
container with an incomplete type? My member objects do not contain
incomplete types. For instance, would the following code be OK?
Thanks. --Omari
#include <boost/shared_ptr.hpp>
#include <vector>
class HasSelf
{
public:
HasSelf(std::vector<HasSelf>& contents);
std::vector<HasSelf> getContents() const;
private:
std::vector<boost::shared_ptr<HasSelf> > _contents;
};