pugixml error in nested class

I’ve got the following C++ code:

#include <ctime>
#include <vector>
#include <pugixml/pugixml.cpp>          //pugixml (version 1.6)

class ClassA
{
    public:
        pugi::xml_document doc;
        ClassA() { }
};

class ClassB
{
    private:
        class ClassB_Child
        {
            public:
                ClassA aInstance;
                long timestamp;

            public:
                ClassB_Child()
                {
                    timestamp = time(NULL);
                    aInstance = ClassA();
                }
        };

    public:
        std::vector<ClassB_Child> vecBChild;

        ClassB()
        {
            vecBChild.push_back(ClassB_Child());
        }
};

int main()
{
    ClassB bInstance;

    return 0;
}

But every time I want to compile it (using MinGW g++ 4.8.1), just many errors are generated:

In file included from c:mingwincludepugixmlpugixml.cpp:17:0,
                 from broken.cpp:3:
c:mingwincludepugixmlpugixml.hpp: In member function 'ClassA& ClassA::operator=(const ClassA&)':
c:mingwincludepugixmlpugixml.hpp:942:23: error: 'const pugi::xml_document& pugi::xml_document::operator=(const pugi::xml_document&)' is private
   const xml_document& operator=(const xml_document&);
                       ^
broken.cpp:5:7: error: within this context
 class ClassA
       ^
broken.cpp: In constructor 'ClassB::ClassB_Child::ClassB_Child()':
broken.cpp:25:16: note: synthesized method 'ClassA& ClassA::operator=(const ClassA&)' first required here 
      aInstance = ClassA();
                ^
In file included from c:mingwincludepugixmlpugixml.cpp:17:0,
                 from broken.cpp:3:
broken.cpp: In instantiation of 'void std::vector<_Tp, _Alloc>::_M_insert_aux(std::vector<_Tp, _Alloc>::iterator, const _Tp&) [with _Tp = ClassB::ClassB_Child; _Alloc = std::allocator<ClassB::ClassB_Child>; std::vector<_Tp, _Alloc>::iterator = __gnu_cxx::__normal_iterator<ClassB::ClassB_Child*, std::vector<ClassB::ClassB_Child> >; typename std::_Vector_base<_Tp, _Alloc>::pointer = ClassB::ClassB_Child*]':
c:mingwlibgccmingw32.8.1includec++bitsstl_vector.h:913:28:   required from 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = ClassB::ClassB_Child; _Alloc = std::allocator<ClassB::ClassB_Child>; std::vector<_Tp, _Alloc>::value_type = ClassB::ClassB_Child]'
broken.cpp:34:38:   required from here
c:mingwincludepugixmlpugixml.hpp:941:3: error: 'pugi::xml_document::xml_document(const pugi::xml_document&)' is private
   xml_document(const xml_document&);
   ^
broken.cpp:5:7: error: within this context
 class ClassA
       ^
broken.cpp:15:9: note: synthesized method 'ClassA::ClassA(const ClassA&)' first required here 
   class ClassB_Child
         ^
In file included from c:mingwlibgccmingw32.8.1includec++vector:69:0,
                 from broken.cpp:2:
c:mingwlibgccmingw32.8.1includec++bitsvector.tcc:329:19: note: synthesized method 'ClassB::ClassB_Child::ClassB_Child(const ClassB::ClassB_Child&)' first required here 
    _Tp __x_copy = __x;
                   ^

I also encountered, that all the errors disappear when I delete the pugi::xml_document doc; line (then the program compiles and runs fine). That means, the error has to be caused by pugixml. What do I have to change in my code to let the program compile properly? Or is it maybe even a bug in pugixml?


Source: c++

Leave a Reply