diff options
Diffstat (limited to 'libstdc++-v3/testsuite/23_containers/list/cons/2.cc')
-rw-r--r-- | libstdc++-v3/testsuite/23_containers/list/cons/2.cc | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/libstdc++-v3/testsuite/23_containers/list/cons/2.cc b/libstdc++-v3/testsuite/23_containers/list/cons/2.cc index ee6864e0333..a38cf7d1bba 100644 --- a/libstdc++-v3/testsuite/23_containers/list/cons/2.cc +++ b/libstdc++-v3/testsuite/23_containers/list/cons/2.cc @@ -20,8 +20,6 @@ #include <list> #include <testsuite_hooks.h> -bool test __attribute__((unused)) = true; - // A nontrivial type. template<typename T> struct A { }; @@ -29,34 +27,29 @@ template<typename T> // Another nontrivial type struct B { }; -// A nontrivial type convertible from an int -struct C { - C(int i) : i_(i) { } - bool operator==(const C& rhs) { return i_ == rhs.i_; } - int i_; -}; - // Fill constructor // // This test verifies the following. -// 23.2.2.1 explicit list(size_type n, const T& v = T(), const a& = Allocator()) -// 23.2.2 const_iterator begin() const -// 23.2.2 const_iterator end() const -// 23.2.2 size_type size() const +// 23.2.2.1 explicit list(size_type n, const T& v = T(), const a& = Allocator()) +// 23.2.2 const_iterator begin() const +// 23.2.2 const_iterator end() const +// 23.2.2 size_type size() const // +template<typename _Tp> void -test02() +cons021() { + bool test __attribute__((unused)) = true; const std::size_t LIST_SIZE = 5; const int INIT_VALUE = 7; std::size_t count; - std::list<int>::const_iterator i; - // nontrivial value_type - std::list< A<B> > list0201(LIST_SIZE); + typedef _Tp list_type; + typedef typename list_type::const_iterator const_iterator; + const_iterator i; // default value - std::list<int> list0202(LIST_SIZE); + list_type list0202(LIST_SIZE); for (i = list0202.begin(), count = 0; i != list0202.end(); ++i, ++count) @@ -65,7 +58,7 @@ test02() VERIFY(list0202.size() == LIST_SIZE); // explicit value - std::list<int> list0203(LIST_SIZE, INIT_VALUE); + list_type list0203(LIST_SIZE, INIT_VALUE); for (i = list0203.begin(), count = 0; i != list0203.end(); ++i, ++count) @@ -74,8 +67,19 @@ test02() VERIFY(list0203.size() == LIST_SIZE); } +template<typename _Tp> +void +cons022() +{ + // nontrivial value_type + typedef _Tp list_type; + const std::size_t LIST_SIZE = 5; + list_type list0201(LIST_SIZE); +} + int main() { - test02(); + cons021<std::list<int> >(); + cons022<std::list< A<B> > >(); return 0; } |