T' illegal use of this type as an expression

i want to check that the typename for a vector_set v is equal to

class vector_set<int>
class vector_set<long>
class vector_set<unsigned char>
class vector_set<double>

by passing T as a parameter list. But I am getting T' illegal use of this type as an expression. How to solve this error ?


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37


using def_con_test_types = boost::mpl::list<int, long, unsigned char, double, char>;
BOOST_AUTO_TEST_CASE_TEMPLATE(type2, T, def_con_test_types) {

	vector_set <T>  v;
	v.insert(T(1));

	BOOST_CHECK_EQUAL(typeid(v).name(), "class vector_set<"+T+">");

}



using def_con_test_types = boost::mpl::list<int, long, unsigned char, double, char>;
BOOST_AUTO_TEST_CASE_TEMPLATE(type4, T, def_con_test_types) {

	vector_set <T>  v1;

	v1.insert(1);
	v1.insert(2);

	vector_set <T> ::iterator it = v1.begin();

	cout << typeid(it).name() << endl;

	BOOST_CHECK_EQUAL(typeid(it).name(),  T  +  "const *");



}





 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <boost/mpl/list.hpp>
#include <boost/mpl/contains.hpp>

using def_con_test_types = boost::mpl::list<int, long, unsigned char, double, char>;

template < typename T > constexpr bool is_def_con_test_type()
{ return boost::mpl::contains< def_con_test_types, T >::value ; }

int main()
{
   static_assert( is_def_con_test_type<int>(), "unexpected" ) ;
   static_assert( !is_def_con_test_type<int*>(), "unexpected" ) ;

   // BOOST_CHECK( is_def_con_test_type<int>() ) ;
}
Topic archived. No new replies allowed.