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 #pragma once
11 
12 #include <limits>
13 
14 #include <rtl/alloc.h>
15 
16 namespace sc {
17 
22 template<typename T, size_t Alignment>
24 {
25 public:
26  typedef T value_type;
27  typedef size_t size_type;
28  typedef std::ptrdiff_t difference_type;
29 
30  typedef T* pointer;
31  typedef const T* const_pointer;
32  typedef T* void_pointer;
33 
34  typedef T& reference;
35  typedef const T& const_reference;
36 
37  template<typename Type2>
38  struct rebind
39  {
41  };
42 
44 
45  template<typename Type2>
47 
48  static void construct(T* p, const value_type& val) { new(p) value_type(val); }
49  static void destroy(T* p)
50  {
51  p->~value_type();
52  (void)p; // avoid bogus MSVC '12 "unreferenced formal parameter" warning
53  }
54 
55  static size_type max_size()
56  {
57  return std::numeric_limits<size_type>::max() / sizeof(value_type);
58  }
59 
60  bool operator== (const AlignedAllocator&) const { return true; }
61  bool operator!= (const AlignedAllocator&) const { return false; }
62 
63  static pointer allocate(size_type n)
64  {
65  return static_cast<pointer>(rtl_allocateAlignedMemory(Alignment, n*sizeof(value_type)));
66  }
67 
68  static void deallocate(pointer p, size_type)
69  {
70  rtl_freeAlignedMemory(p);
71  }
72 };
73 
74 }
75 
76 /* 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)
CAUTION! The following defines must be in the same namespace as the respective type.
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