PPL  1.2
Temp_defs.hh
Go to the documentation of this file.
1 /* Temp_* classes declarations.
2  Copyright (C) 2001-2010 Roberto Bagnara <bagnara@cs.unipr.it>
3  Copyright (C) 2010-2016 BUGSENG srl (http://bugseng.com)
4 
5 This file is part of the Parma Polyhedra Library (PPL).
6 
7 The PPL is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 The PPL is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software Foundation,
19 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA.
20 
21 For the most up-to-date information see the Parma Polyhedra Library
22 site: http://bugseng.com/products/ppl/ . */
23 
24 #ifndef PPL_Temp_defs_hh
25 #define PPL_Temp_defs_hh 1
26 
27 #include "meta_programming.hh"
28 #include "Slow_Copy.hh"
29 
30 namespace Parma_Polyhedra_Library {
31 
32 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
33 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
35 template <typename T>
36 class Temp_Item {
37 public:
39  static Temp_Item& obtain();
40 
42  static void release(Temp_Item& p);
43 
45  T& item();
46 
47 private:
49  T item_;
50 
53 
54  class Free_List {
55  public:
56  Free_List();
57  ~Free_List();
59  private:
60  Free_List(const Free_List&); // Not implemented.
61  Free_List& operator=(const Free_List&); // Not implemented.
62  }; // class Free_List
63 
64  friend class Free_List;
65 
67  static Temp_Item*& free_list_ref();
68 
70  Temp_Item();
71 
73  Temp_Item(const Temp_Item&);
74 
76  Temp_Item& operator=(const Temp_Item&);
77 };
78 
79 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
80 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
82 template <typename T>
84 public:
87 
90 
92  T& item();
93 
94 private:
97 
100 
103 };
104 
105 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
106 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
108 template <typename T>
110 public:
113 
115  T& item();
116 
117 private:
120 
123 
125  T item_;
126 };
127 
128 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
129 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
131 template <typename T, typename Enable = void>
133 
134 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
135 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
137 template <typename T>
138 class Dirty_Temp<T, typename Enable_If<Slow_Copy<T>::value>::type>
139  : public Temp_Reference_Holder<T> {
140 };
141 
142 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
143 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
145 template <typename T>
146 class Dirty_Temp<T, typename Enable_If<!Slow_Copy<T>::value>::type>
147  : public Temp_Value_Holder<T> {
148 };
149 
150 } // namespace Parma_Polyhedra_Library
151 
152 #include "Temp_inlines.hh"
153 #include "Temp_templates.hh"
154 
155 #endif // !defined(PPL_Temp_defs_hh)
A structure for the efficient handling of temporaries.
Definition: Temp_defs.hh:132
T & item()
Returns the value of the held item.
T item_
The encapsulated item.
Definition: Temp_defs.hh:49
T & item()
Returns a reference to the held item.
Definition: Temp_inlines.hh:90
Temp_Item< T > & held
The held item, encapsulated.
Definition: Temp_defs.hh:102
Temp_Value_Holder & operator=(const Temp_Value_Holder &)
Assignment operator: private and intentionally not implemented.
Free_List & operator=(const Free_List &)
An holder for a reference to a temporary object.
Definition: Temp_defs.hh:83
A pool of temporary items of type T.
Definition: Temp_defs.hh:36
Temp_Value_Holder()
Constructs a fake holder.
Definition: Temp_inlines.hh:96
An (fake) holder for the value of a temporary object.
Definition: Temp_defs.hh:109
Coefficient value
Definition: PIP_Tree.cc:618
Temp_Item()
Default constructor.
Definition: Temp_inlines.hh:33
T & item()
Returns a reference to the encapsulated item.
Definition: Temp_inlines.hh:39
The entire library is confined to this namespace.
Definition: version.hh:61
Temp_Item * next
Pointer to the next item in the free list.
Definition: Temp_defs.hh:52
Temp_Item & operator=(const Temp_Item &)
Assignment operator: private and intentionally not implemented.
static void release(Temp_Item &p)
Releases the temporary item p.
Definition: Temp_inlines.hh:71
static Temp_Item *& free_list_ref()
Head of the free list.
Definition: Temp_inlines.hh:51
A class that provides a type member called type equivalent to T if and only if b is true...
static Temp_Item & obtain()
Obtains a reference to a temporary item.
Definition: Temp_inlines.hh:58
Temp_Reference_Holder & operator=(const Temp_Reference_Holder &)
Assignment operator: private and intentionally not implemented.
Temp_Reference_Holder()
Constructs an holder holding a dirty temp.
Definition: Temp_inlines.hh:78