LibreOffice Module sc (master)  1
stlalgorithm.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  */
9 
10 #ifndef INCLUDED_SC_INC_STLALGORITHM_HXX
11 #define INCLUDED_SC_INC_STLALGORITHM_HXX
12 
13 #include <limits>
14 
15 #include <rtl/alloc.h>
16 
17 namespace sc {
18 
23 template<typename T, size_t Alignment>
25 {
26 public:
27  typedef T value_type;
28  typedef size_t size_type;
29  typedef std::ptrdiff_t difference_type;
30 
31  typedef T* pointer;
32  typedef const T* const_pointer;
33  typedef T* void_pointer;
34 
35  typedef T& reference;
36  typedef const T& const_reference;
37 
38  template<typename Type2>
39  struct rebind
40  {
42  };
43 
45 
46  template<typename Type2>
48 
49  static void construct(T* p, const value_type& val) { new(p) value_type(val); }
50  static void destroy(T* p)
51  {
52  p->~value_type();
53  (void)p; // avoid bogus MSVC '12 "unreferenced formal parameter" warning
54  }
55 
56  static size_type max_size()
57  {
58  return std::numeric_limits<size_type>::max() / sizeof(value_type);
59  }
60 
61  bool operator== (const AlignedAllocator&) const { return true; }
62  bool operator!= (const AlignedAllocator&) const { return false; }
63 
64  static pointer allocate(size_type n)
65  {
66  return static_cast<pointer>(rtl_allocateAlignedMemory(Alignment, n*sizeof(value_type)));
67  }
68 
69  static void deallocate(pointer p, size_type)
70  {
71  rtl_freeAlignedMemory(p);
72  }
73 };
74 
75 }
76 
77 #endif
78 
79 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
AlignedAllocator< Type2, Alignment > other
AlignedAllocator(const AlignedAllocator< Type2, Alignment > &)
std::ptrdiff_t difference_type
static void destroy(T *p)
bool operator!=(const AlignedAllocator &) const
static pointer allocate(size_type n)
bool operator==(const AlignedAllocator &) const
static void construct(T *p, const value_type &val)
Custom allocator for STL container to ensure that the base address of allocated storage is aligned to...
static void deallocate(pointer p, size_type)
static size_type max_size()
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo