#include <vector>
class A {
public:
A() {}
};
template<typename T>
void foo(const T &p) {
union {
typename std::remove_const<
typename std::remove_reference<
decltype(p[0])
>::type
>::type
must_be_POD;
} bar;
}
int main() {
int b[10];
A c[10];
int *d = b;
A *e = c;
foo(std::vector<int>(1)); // OK
foo(b); // OK
foo(d); // OK
// foo(std::vector<A>(1)); // ERROR
// foo(c); // ERROR
// foo(e); // ERROR
return 0;
}
I2luY2x1ZGUgPHZlY3Rvcj4KY2xhc3MgQSB7CiBwdWJsaWM6CiAgQSgpIHt9Cn07Cgp0ZW1wbGF0ZTx0eXBlbmFtZSBUPgp2b2lkIGZvbyhjb25zdCBUICZwKSB7CiAgdW5pb24gewogICAgdHlwZW5hbWUgc3RkOjpyZW1vdmVfY29uc3Q8CiAgICAgIHR5cGVuYW1lIHN0ZDo6cmVtb3ZlX3JlZmVyZW5jZTwKICAgICAgICBkZWNsdHlwZShwWzBdKQogICAgICA+Ojp0eXBlCiAgICA+Ojp0eXBlCiAgICBtdXN0X2JlX1BPRDsKICAgIAogIH0gYmFyOwp9IAoKaW50IG1haW4oKSB7CiAgaW50IGJbMTBdOwogIEEgICBjWzEwXTsKICBpbnQgKmQgPSBiOwogIEEgICAqZSA9IGM7CiAgZm9vKHN0ZDo6dmVjdG9yPGludD4oMSkpOyAvLyBPSwogIGZvbyhiKTsgICAgICAgICAgICAgICAgICAgLy8gT0sKICBmb28oZCk7ICAgICAgICAgICAgICAgICAgIC8vIE9LCiAvLyBmb28oc3RkOjp2ZWN0b3I8QT4oMSkpOyAgIC8vIEVSUk9SCiAvLyBmb28oYyk7ICAgICAgICAgICAgICAgICAgIC8vIEVSUk9SCiAvLyBmb28oZSk7ICAgICAgICAgICAgICAgICAgIC8vIEVSUk9SCiAgcmV0dXJuIDA7Cn0K