Apache Qpid - AMQP Messaging for Java JMS, C++, Python, Ruby, and .NET Apache Qpid Documentation
InlineVector.h
Go to the documentation of this file.
1 #ifndef QPID_INLINEVECTOR_H
2 #define QPID_INLINEVECTOR_H
3 
4 /*
5  *
6  * Licensed to the Apache Software Foundation (ASF) under one
7  * or more contributor license agreements. See the NOTICE file
8  * distributed with this work for additional information
9  * regarding copyright ownership. The ASF licenses this file
10  * to you under the Apache License, Version 2.0 (the
11  * "License"); you may not use this file except in compliance
12  * with the License. You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing,
17  * software distributed under the License is distributed on an
18  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19  * KIND, either express or implied. See the License for the
20  * specific language governing permissions and limitations
21  * under the License.
22  *
23  */
24 
25 #include "qpid/InlineAllocator.h"
26 #include <vector>
27 
28 namespace qpid {
29 
40 template <class T, size_t Max, class Alloc=std::allocator<T> >
41 class InlineVector : public std::vector<T, InlineAllocator<Alloc, Max> >
42 {
43  typedef std::vector<T, InlineAllocator<Alloc, Max> > Base;
44  public:
45  typedef typename Base::allocator_type allocator_type;
46  typedef typename Base::value_type value_type;
47  typedef typename Base::size_type size_type;
48 
49  explicit InlineVector(const allocator_type& a=allocator_type()) : Base(a) {
50  this->reserve(Max);
51  }
52 
53  explicit InlineVector(size_type n, const value_type& x = value_type(),
54  const allocator_type& a=allocator_type()) : Base(a)
55  {
56  this->reserve(std::max(n, Max));
57  this->insert(this->end(), n, x);
58  }
59 
60  InlineVector(const InlineVector& x) : Base() {
61  this->reserve(std::max(x.size(), Max));
62  *this = x;
63  }
64 };
65 
66 } // namespace qpid
67 
68 #endif

Qpid C++ API Reference
Generated on Fri Feb 22 2013 for Qpid C++ Client API by doxygen 1.8.3