Code

Fix fallback icon loading order for icons with legacy names.
[inkscape.git] / src / gc-alloc.h
1 /*
2  * Inkscape::GC::Alloc - GC-aware STL allocator
3  *
4  * Copyright 2004 MenTaLguY <mental@rydia.net>
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * See the file COPYING for details.
12  *
13  */
15 #ifndef SEEN_INKSCAPE_GC_ALLOC_H
16 #define SEEN_INKSCAPE_GC_ALLOC_H
18 #include <limits>
19 #include "gc-core.h"
21 namespace Inkscape {
23 namespace GC {
25 template <typename T, CollectionPolicy collect>
26 class Alloc {
27 public:
28     typedef T value_type;
29     typedef T *pointer;
30     typedef T const *const_pointer;
31     typedef T &reference;
32     typedef T const &const_reference;
33     typedef std::size_t size_type;
34     typedef std::ptrdiff_t difference_type;
36     template <typename U>
37     struct rebind { typedef Alloc<U, collect> other; };
39     Alloc() {}
40     template <typename U> Alloc(Alloc<U, collect> const &) {}
42     pointer address(reference r) { return &r; }
43     const_pointer address(const_reference r) { return &r; }
45     size_type max_size() const {
46         return std::numeric_limits<std::size_t>::max() / sizeof(T);
47     }
49     pointer allocate(size_type count, void const * =NULL) {
50         return static_cast<pointer>(::operator new(count * sizeof(T), SCANNED, collect));
51     }
53     void construct(pointer p, const_reference value) {
54         new (static_cast<void *>(p)) T(value);
55     }
56     void destroy(pointer p) { p->~T(); }
58     void deallocate(pointer p, size_type) { ::operator delete(p, GC); }
59 };
61 // allocators with the same collection policy are interchangable
63 template <typename T1, typename T2,
64           CollectionPolicy collect1, CollectionPolicy collect2>
65 bool operator==(Alloc<T1, collect1> const &, Alloc<T2, collect2> const &) {
66     return collect1 == collect2;
67 }
69 template <typename T1, typename T2,
70           CollectionPolicy collect1, CollectionPolicy collect2>
71 bool operator!=(Alloc<T1, collect1> const &, Alloc<T2, collect2> const &) {
72     return collect1 != collect2;
73 }
75 }
77 }
79 #endif
80 /*
81   Local Variables:
82   mode:c++
83   c-file-style:"stroustrup"
84   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
85   indent-tabs-mode:nil
86   fill-column:99
87   End:
88 */
89 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :