Search code examples
c++c++11boostforward-declarationboost-propertytree

Forward declaration of typedef


I have the following code:

namespace boost {
    namespace property_tree {
        template<class Key, class Data, class KeyCompare>
        class basic_ptree;

        typedef basic_ptree<std::string, std::string, std::less<std::string> > ptree;
    }
}

class JsonReader {

public:
    JsonReader();

    ~JsonReader() { };

    void processValuation(std::vector<Simulation> &simulations);

private:

    std::string processOptionParams(const ptree::value_type &node);

    void loadConfig(std::string filename);

    std::shared_ptr<boost::property_tree::ptree> jsonTree_;
};

Everything is fine, but I'm not sure how to forward declare ptree::value_type. Any ideas how can it be done?

The file with value_type definition you can find here http://www.boost.org/doc/libs/1_60_0/boost/property_tree/ptree.hpp


Solution

  • You can't forward declare a type member off of a forward declared type. That leaves you with either just pulling out the actual definition of value_type from ptree (not recommended), or simply including the full header ptree.hpp.

    Once you need the internals of a class in your header file, forward-declaration isn't an option.