Re: SFINAE question 2

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux