| 1 | #include <boost/noncopyable.hpp>
|
|---|
| 2 | #include <boost/range/numeric.hpp>
|
|---|
| 3 |
|
|---|
| 4 | #include <vector>
|
|---|
| 5 |
|
|---|
| 6 | template <class T>
|
|---|
| 7 | class NCVec : boost::noncopyable
|
|---|
| 8 | {
|
|---|
| 9 | std::vector<T> _actual;
|
|---|
| 10 |
|
|---|
| 11 | public:
|
|---|
| 12 | typedef typename std::vector<T>::const_iterator const_iterator;
|
|---|
| 13 |
|
|---|
| 14 | const_iterator begin() const
|
|---|
| 15 | {
|
|---|
| 16 | return _actual.begin();
|
|---|
| 17 | }
|
|---|
| 18 |
|
|---|
| 19 | const_iterator end() const
|
|---|
| 20 | {
|
|---|
| 21 | return _actual.end();
|
|---|
| 22 | }
|
|---|
| 23 |
|
|---|
| 24 | void emplace_back(T&& t)
|
|---|
| 25 | {
|
|---|
| 26 | _actual.emplace_back(std::forward<T>(t));
|
|---|
| 27 | }
|
|---|
| 28 | };
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 | void f()
|
|---|
| 32 | {
|
|---|
| 33 | NCVec<int> a;
|
|---|
| 34 |
|
|---|
| 35 | boost::accumulate(a, 0);
|
|---|
| 36 | }
|
|---|