LINUX.ORG.RU

История изменений

Исправление wolverin, (текущая версия) :

хз, не работает так тоже

hpp
class CJSON
{
private:
    struct impl;
    std::unique_ptr<impl> pimpl;

public:
    CJSON(const char *, const int);
    ~CJSON() {}
};

cpp
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/json_parser.hpp>

#include "DownloaderJSON.hpp"

struct CJSON::impl
{
    boost::property_tree::ptree pt;
};

CJSON::CJSON(const char * msg, const int lmsg)
    : pimpl(std::make_unique<impl>())
{
    std::stringstream ss;
    ss.write(msg, lmsg);
}
...

на объявление auto json = std::make_unique<CJSON>(msg, msgLen) все та же ошибка размера типа

/usr/include/c++/8/bits/unique_ptr.h: In instantiation of ‘void std::default_delete<_Tp>::operator()(_Tp*) const [with _Tp = CJSON::impl]’:
/usr/include/c++/8/bits/unique_ptr.h:274:17:   required from ‘std::unique_ptr<_Tp, _Dp>::~unique_ptr() [with _Tp = CJSON::impl; _Dp = std::default_delete<CJSON::impl>]’
DownloaderJSON.hpp:15:14:   required from here
/usr/include/c++/8/bits/unique_ptr.h:79:16: error: invalid application of ‘sizeof’ to incomplete type ‘CJSON::impl’
  static_assert(sizeof(_Tp)>0,                ^~~~~~~~~~~

Исходная версия wolverin, :

хз, не работает так тоже

hpp
class CJSON
{
private:
    struct impl;
    std::unique_ptr<impl> pimpl;

public:
    CJSON(const char *, const int);
    ~CJSON() {}
};

cpp
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/json_parser.hpp>

#include "DownloaderJSON.hpp"

struct CJSON::impl
{
    boost::property_tree::ptree pt;
}

CJSON::CJSON(const char * msg, const int lmsg)
    : pimpl(std::make_unique<impl>())
{
    std::stringstream ss;
    ss.write(msg, lmsg);
}
...

на объявление auto json = std::make_unique<CJSON>(msg, msgLen) все та же ошибка размера типа

/usr/include/c++/8/bits/unique_ptr.h: In instantiation of ‘void std::default_delete<_Tp>::operator()(_Tp*) const [with _Tp = CJSON::impl]’:
/usr/include/c++/8/bits/unique_ptr.h:274:17:   required from ‘std::unique_ptr<_Tp, _Dp>::~unique_ptr() [with _Tp = CJSON::impl; _Dp = std::default_delete<CJSON::impl>]’
DownloaderJSON.hpp:15:14:   required from here
/usr/include/c++/8/bits/unique_ptr.h:79:16: error: invalid application of ‘sizeof’ to incomplete type ‘CJSON::impl’
  static_assert(sizeof(_Tp)>0,
                ^~~~~~~~~~~
DownloaderJSON.cpp:6:1: error: new types may not be defined in a return type
 struct CJSON::impl
 ^~~~~~
DownloaderJSON.cpp:6:1: note: (perhaps a semicolon is missing after the definition of ‘CJSON::impl’)
DownloaderJSON.cpp:38:46: error: return type specification for constructor invalid
 CJSON::CJSON(const char * msg, const int lmsg)