What means ::type in template

If I am compiling HBase native client with folly library, is error in folly:
/usr/local/include/folly/functional/Invoke.h
// mimic: std::invoke_result_t, C++17
template <typename F, typename... Args>
using invoke_result_t = typename invoke_result<F, Args...>::type;

or If I am using -std=c++17 with gcc-8 similar is in file
/usr/include/c++/8/type_traits

error is:
/usr/include/c++/8/type_traits|2670|error: no type named ‘type’ in ‘struct std::invoke_result<hbase::AsyncBatchRpcRetryingCaller<REQ, RESP>::GroupAndSend(const std::vector<std::shared_ptr<hbase::Action> >&, int32_t) [with REQ = std::shared_ptr<hbase::Row>; RESP = std::shared_ptr<hbase::Result>; int32_t = int]::<lambda(std::vector<folly::Try<std::shared_ptr<hbase::RegionLocation> > >&)>, folly::Try<std::vector<folly::Try<std::shared_ptr<hbase::RegionLocation> >, std::allocator<folly::Try<std::shared_ptr<hbase::RegionLocation> > > > >&&>’|

there is many code - where should be type 'type' ?
invoke_result is a metafunction that returns a type. The 'type' member not being defined means that the metafunction cannot determine a type for the template parameters that were passed.

For example:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
template <int N>
struct sample_metafunction{};

template <>
struct sample_metafunction<0>{
    typename int type;
};

template <>
struct sample_metafunction<1>{
    typename std::string type;
};

template <>
struct sample_metafunction<2>{
    typename double type;
};

typename sample_metafunction<0>::type type0; // OK - type0 is int
typename sample_metafunction<1>::type type1; // OK - type1 is std::string
typename sample_metafunction<2>::type type2; // OK - type2 is double
typename sample_metafunction<3>::type type3; // Error. 
Last edited on
Topic archived. No new replies allowed.