#include <iostream>
#include <type_traits>
#include <vector>
using namespace std;
struct bar{
} ;
template < typename T>
void foo( const T & t) {
static_assert( std:: is_same < typename T:: value_type ,bar> :: value
,"element type must be bar"
) ;
}
int main( ) {
// your code goes here
foo( std:: vector < bar> ( ) ) ;
foo( std:: vector < int > ( ) ) ;
return 0 ;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dHlwZV90cmFpdHM+CiNpbmNsdWRlIDx2ZWN0b3I+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CnN0cnVjdCBiYXJ7CgkKfTsKdGVtcGxhdGU8dHlwZW5hbWUgVD4Kdm9pZCBmb28oY29uc3QgVCAmdCl7CglzdGF0aWNfYXNzZXJ0KHN0ZDo6aXNfc2FtZTx0eXBlbmFtZSBUOjp2YWx1ZV90eXBlLGJhcj46OnZhbHVlCgkgLCJlbGVtZW50IHR5cGUgbXVzdCBiZSBiYXIiCgkpOwp9CgppbnQgbWFpbigpIHsKCS8vIHlvdXIgY29kZSBnb2VzIGhlcmUKCQoJZm9vKHN0ZDo6dmVjdG9yPGJhcj4oKSk7Cglmb28oc3RkOjp2ZWN0b3I8aW50PigpKTsKCQoJcmV0dXJuIDA7Cn0=
compilation info
prog.cpp: In instantiation of ‘void foo(const T&) [with T = std::vector<int>]’:
prog.cpp:19:24: required from here
prog.cpp:10:2: error: static assertion failed: element type must be bar
static_assert(std::is_same<typename T::value_type,bar>::value
^
stdout