SFINAE question 2
Onay Urfalioglu
onay.urfalioglu@gmail.com
Wed Aug 22 22:37:00 GMT 2012
On 08/22/2012 11:01 PM, Jonathan Wakely wrote:
> template<typename T>
> struct HasRandomAccessOp {
> typedef decltype(std::declval<T>()[0]) test_type;
> };
>
> template<typename T, typename T_VECTOR,
> typename = typename HasRandomAccessOp<T_VECTOR>::test_type>
> int operator*(const T &l, const T_VECTOR &r) {
> return 1;
> }
Hi Jonathan,
yes, this works as expected ;-)
I wonder whether it is possible to overload the operator*() to have two
versions:
- one for all T_VECTOR - types having operator[]
- one for all T_VECTOR - types not having operator[] but providing
say a forward iterator, like std::list
(This is just a toy requirement, I am aware that one can implement this
in other ways too...)
You see I am painfully missing some C++11 concepts functionality here...
Cheers,
onay
More information about the Gcc-help
mailing list