12345678910111213141516171819202122
using def_con_test_types = boost::mpl::list<int, long, unsigned char, double, std::string, char>; BOOST_AUTO_TEST_CASE_TEMPLATE(capacity2, T, def_con_test_types) { vector_set <T> v ; if (T == int) { v.insert(1) } else if (T == long) { v.insert(2); } //v.insert(1); //cout << "capacity " << v.capacity() << endl; BOOST_TEST(v.capacity() >= v.size()); BOOST_CHECK(v.capacity() >= v.size()); }
12345678
#include <type_traits> template < typename T > void foo() { // if T==int value = 1, else if T==long value = 2, else value = 3 constexpr long long value = std::is_same<T,int>::value ? 1 : ( std::is_same<T,long>::value ? 2 : 3 ) ; }