Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
25.uninitialized.copy.stdcxx-976.cpp
Go to the documentation of this file.
1
29#include <memory>
30#include <iterator>
31
32
33template <class T>
34struct InputIterator: std::iterator<std::input_iterator_tag, T>
35{
36 T *p_;
37
38 InputIterator (T *p): p_ (p) { }
40
41 InputIterator& operator= (const InputIterator &rhs)
42 { p_ = rhs.p_; return *this; }
43
44 T operator* () const { return *p_; }
45
46 InputIterator& operator++ () { return ++p_, *this; }
47 InputIterator operator++ (int) {
48 return ++p_, InputIterator (p_ - 1);
49 }
50
51 bool operator== (const InputIterator &rhs) const { return p_ == rhs.p_; }
52 bool operator!= (const InputIterator &rhs) const { return p_ != rhs.p_; }
53};
54
55class Test
56{
57 // private and not defined
58 Test (const Test&);
59
60public:
61 Test () {}
62 Test (Test&) {}
63 ~Test () {}
64};
65
66
67int main ()
68{
70 typedef InputIterator<const char> CIter;
71 typedef InputIterator<volatile char> VIter;
73
74 char src [5] = "abcd";
75 char dst [5];
76
77 std::uninitialized_copy (Iter (src), Iter (src + 5), dst);
78 std::uninitialized_copy (CIter (src), CIter (src + 5), dst);
79 std::uninitialized_copy (VIter (src), VIter (src + 5), dst);
80 std::uninitialized_copy (CVIter (src), CVIter (src + 5), dst);
81
82
83 Test test;
84 volatile Test vtest;
85
86 std::uninitialized_copy (&test, &test, &test);
87 std::uninitialized_copy (&test, &test, &vtest);
88
89 return 0;
90}
#define T
Definition 17.names.cpp:163
#define rhs
Definition 17.names.cpp:536
#define p_
Definition 17.names.cpp:186
#define InputIterator
Definition 17.names.cpp:481
#define p
Definition 17.names.cpp:132
const plus_asgn< T > & operator*(const plus_asgn< T > &lhs, const plus_asgn< T > &rhs)
std::ostream_iterator< int, char, std::char_traits< char > > Iter
Definition alg7.cpp:64
bool operator==(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
Definition json.h:14737
bool operator!=(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
Definition json.h:14762
InputIterator(const InputIterator &rhs)