I am looking at the code of a file distributed by Adobe:
The part of the code I am interested in is:
struct any_json_helper_t {
typedef any value_type;
typedef string key_type;
typedef string string_type;
typedef unordered_map<key_type, value_type> object_type;
typedef vector<value_type> array_type;
typedef object_type::value_type pair_type;
Error:
clang++ -o json json.cpp -std=c++14
json.cpp:105:13: error: no type named 'value_type' in 'std::__1::unordered_map<std::__1::basic_string<char>, any,
std::__1::hash<std::__1::basic_string<char> >, std::__1::equal_to<std::__1::basic_string<char> >,
std::__1::allocator<std::__1::pair<const std::__1::basic_string<char>, any> > >'; did you mean simply 'value_type'?
typedef object_type::value_type pair_type;
^~~~~~~~~~~~~~~~~
value_t
json.cpp:100:17: note: 'value_type' declared here
typedef any value_type;
Am I doing something wrong? (it seems to implicitely use any
instead of value_type
and thus can't find object_type::value_type
). How could I make this work (beside using value_type
directly of course as suggested by compiler)?
any
is not available in c++14 (as mentioned in an answer). I implemented my own version in this particular case.
struct any
{
public:
any() : ptr(nullptr) {}
private:
struct base_t
{
virtual ~base_t() {}
};
base_t* ptr { nullptr };
};
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.