Skip to content

Problem with collections saving pointers #3

@jseto

Description

@jseto

Try the code below it test_jrtti.cpp and check res.txt file. String s is not streamed!!!

struct Test {
    std::string str;
    std::string * ptr;
};

typedef std::vector< Test * > TestVector;

TEST_F(MetaTypeTest, CollectionOfStrings) {
    declare< Test >()
        .property("str",&Test::str)
        .property("ptr",&Test::ptr);
    declareCollection< TestVector >();

    TestVector elements;
    std::string s = "fins dema **************";

    for ( int i = 0; i < 2; ++i ) {
        Test * ptr = new Test();
        ptr->ptr = &s;
        ptr->str = "hola";
        elements.push_back( ptr );
    }

    std::string str = metatype< TestVector >().toStr( &elements );
    std::ofstream f( "res.txt" );
    f << str;
//  EXPECT_EQ("double", mClass()["testDouble"].metatype().name());

    for ( TestVector::iterator it = elements.begin(); it != elements.end(); ++it ) {
        delete *it;
    }                       
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions