SFINAE question 2

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

 



The following code compiles fine with g++-4.7.1 in c++11 mode, but I think it should give errors for the last source line "auto res2 = 2 * std::list<int>();" (SFINAE ?)
// compile cmd:
// g++ c++11-test.cpp -o cpp11-test -std=c++11

#include <vector>
#include <list>

template<typename T>
struct HasRandomAccessOp {
    HasRandomAccessOp(const T &v) {
        typedef decltype(v[0]) test_type;
    }
};

template<typename T, typename T_VECTOR>
int operator*(const T &l, const T_VECTOR &r) {
typedef decltype(HasRandomAccessOp<T_VECTOR>(r)) random_access_test_type;
    return 1;
}

int main() {
    std::vector<int> iv = {1,2};

    auto res1 = 1 * iv;
    auto res2 = 2 * std::list<int>();
}



[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