If i give
typedef std::vector<int> v;
Then it can be used below to write the type of constant iterator (an alternative is to use v::const_iterator, but it depends on the type of element const_iteratorthat is explicitly defined in the class.
typedef typename std::result_of<decltype(&v::cbegin)(v*)>::type const_iterator;
In fact, we can verify that the above does the way we want.
static_assert(std::is_same<const_iterator, typename v::const_iterator>::value);
However, I found a compiler error below.
typedef typename std::result_of<decltype(&v::begin)(v*)>::type iterator;
The compiler complains that the method is overloaded (const modifier) ββand cannot be unambiguously resolved. However, I cannot find the syntax to eliminate the ambiguity. At a minimum, we expect it to be unambiguous below, because only the const version can work on a const object. However, even the following is likewise problematic.
typedef typename std::result_of<decltype(&v::begin)(const v*)>::type const_iterator2;
How can I refer to a specific version of const or nonconst for starters?