Audacity  3.0.3
MemoryX.h
Go to the documentation of this file.
1 #ifndef __AUDACITY_MEMORY_X_H__
2 #define __AUDACITY_MEMORY_X_H__
3 
4 // C++ standard header <memory> with a few extensions
5 #include <memory>
6 #include <cstdlib> // Needed for free.
7 #ifndef safenew
8 #define safenew new
9 #endif
10 
11 #include <functional>
12 
13 #if !(_MSC_VER >= 1800 || __cplusplus >= 201402L)
14 /* replicate the very useful C++14 make_unique for those build environments
15 that don't implement it yet.
16 typical usage:
17 auto p = std::make_unique<Myclass>(ctorArg1, ctorArg2, ... ctorArgN);
18 p->DoSomething();
19 auto q = std::make_unique<Myclass[]>(count);
20 q[0].DoSomethingElse();
21 
22 The first hides naked NEW and DELETE from the source code.
23 The second hides NEW[] and DELETE[]. Both of course ensure destruction if
24 you don't use something like std::move(p) or q.release(). Both expressions require
25 that you identify the type only once, which is brief and less error prone.
26 
27 (Whereas this omission of [] might invite a runtime error:
28 std::unique_ptr<Myclass> q { safenew Myclass[count] }; )
29 
30 Some C++11 tricks needed here are (1) variadic argument lists and
31 (2) making the compile-time dispatch work correctly. You can't have
32 a partially specialized template function, but you get the effect of that
33 by other metaprogramming means.
34 */
35 
36 namespace std {
37  // For overloading resolution
38  template <typename X> struct __make_unique_result {
39  using scalar_case = unique_ptr<X>;
40  };
41 
42  // Partial specialization of the struct for array case
43  template <typename X> struct __make_unique_result<X[]> {
44  using array_case = unique_ptr<X[]>;
45  using element = X;
46  };
47 
48  // Now the scalar version of unique_ptr
49  template<typename X, typename... Args> inline
51  make_unique(Args&&... args)
52  {
54  { safenew X(forward<Args>(args)...) };
55  }
56 
57  // Now the array version of unique_ptr
58  // The compile-time dispatch trick is that the non-existence
59  // of the scalar_case type makes the above overload
60  // unavailable when the template parameter is explicit
61  template<typename X> inline
62  typename __make_unique_result<X>::array_case
63  make_unique(size_t count)
64  {
66  { safenew typename __make_unique_result<X>::element[count] };
67  }
68 }
69 #endif
70 
71 /*
72  * ArrayOf<X>
73  * Not to be confused with std::array (which takes a fixed size) or std::vector
74  * This maintains a pointer allocated by NEW X[]. It's cheap: only one pointer,
75  * with no size and capacity information for resizing as for vector, and if X is
76  * a built-in numeric or pointer type, by default there is no zero filling at
77  * allocation time.
78  */
79 
80 template<typename X>
81 class ArrayOf : public std::unique_ptr<X[]>
82 {
83 public:
84  ArrayOf() {}
85 
86  template<typename Integral>
87  explicit ArrayOf(Integral count, bool initialize = false)
88  {
89  static_assert(std::is_unsigned<Integral>::value, "Unsigned arguments only");
90  reinit(count, initialize);
91  }
92 
93  //ArrayOf(const ArrayOf&) PROHIBITED;
94  ArrayOf(const ArrayOf&) = delete;
95  ArrayOf(ArrayOf&& that)
96  : std::unique_ptr < X[] >
97  (std::move((std::unique_ptr < X[] >&)(that)))
98  {
99  }
101  {
102  std::unique_ptr<X[]>::operator=(std::move(that));
103  return *this;
104  }
105  ArrayOf& operator= (std::unique_ptr<X[]> &&that)
106  {
107  std::unique_ptr<X[]>::operator=(std::move(that));
108  return *this;
109  }
110 
111  template< typename Integral >
112  void reinit(Integral count,
113  bool initialize = false)
114  {
115  static_assert(std::is_unsigned<Integral>::value, "Unsigned arguments only");
116  if (initialize)
117  // Initialize elements (usually, to zero for a numerical type)
118  std::unique_ptr<X[]>::reset(safenew X[count]{});
119  else
120  // Avoid the slight initialization overhead
121  std::unique_ptr<X[]>::reset(safenew X[count]);
122  }
123 };
124 
134 template<typename X>
135 class ArraysOf : public ArrayOf<ArrayOf<X>>
136 {
137 public:
138  ArraysOf() {}
139 
140  template<typename Integral>
141  explicit ArraysOf(Integral N)
142  : ArrayOf<ArrayOf<X>>( N )
143  {}
144 
145  template<typename Integral1, typename Integral2 >
146  ArraysOf(Integral1 N, Integral2 M, bool initialize = false)
147  : ArrayOf<ArrayOf<X>>( N )
148  {
149  static_assert(std::is_unsigned<Integral1>::value, "Unsigned arguments only");
150  static_assert(std::is_unsigned<Integral2>::value, "Unsigned arguments only");
151  for (size_t ii = 0; ii < N; ++ii)
152  (*this)[ii] = ArrayOf<X>{ M, initialize };
153  }
154 
155  //ArraysOf(const ArraysOf&) PROHIBITED;
156  ArraysOf(const ArraysOf&) =delete;
158  {
159  ArrayOf<ArrayOf<X>>::operator=(std::move(that));
160  return *this;
161  }
162 
163  template< typename Integral >
164  void reinit(Integral count)
165  {
166  ArrayOf<ArrayOf<X>>::reinit( count );
167  }
168 
169  template< typename Integral >
170  void reinit(Integral count, bool initialize)
171  {
172  ArrayOf<ArrayOf<X>>::reinit( count, initialize );
173  }
174 
175  template<typename Integral1, typename Integral2 >
176  void reinit(Integral1 countN, Integral2 countM, bool initialize = false)
177  {
178  static_assert(std::is_unsigned<Integral1>::value, "Unsigned arguments only");
179  static_assert(std::is_unsigned<Integral2>::value, "Unsigned arguments only");
180  reinit(countN, false);
181  for (size_t ii = 0; ii < countN; ++ii)
182  (*this)[ii].reinit(countM, initialize);
183  }
184 };
185 
198 // Placement-NEW is used below, and that does not cooperate with the DEBUG_NEW for Visual Studio
199 #ifdef _DEBUG
200 #ifdef _MSC_VER
201 #undef new
202 
203 // wx/any.h also uses Placement-NEW so include it before redefining "new" at comment:
204 // "Restore definition of debug new"
205 #include <wx/any.h>
206 #endif
207 #endif
208 
209 template<typename X>
210 class Optional {
211 public:
212 
213  using value_type = X;
214 
215  // Construct as NULL
216  Optional() {}
217 
218  // Supply the copy and move, so you might use this as a class member too
219  Optional(const Optional &that)
220  {
221  if (that)
222  emplace(*that);
223  }
224 
226  {
227  if (this != &that) {
228  if (that)
229  emplace(*that);
230  else
231  reset();
232  }
233  return *this;
234  }
235 
237  {
238  if (that)
239  emplace(::std::move(*that));
240  }
241 
243  {
244  if (this != &that) {
245  if (that)
246  emplace(::std::move(*that));
247  else
248  reset();
249  }
250  return *this;
251  }
252 
258  template<typename... Args>
259  X& emplace(Args&&... args)
260  {
261  // Lose any old value
262  reset();
263  // emplace NEW value
264  pp = safenew(address()) X(std::forward<Args>(args)...);
265  return **this;
266  }
267 
268  // Destroy any object that was built in it
270  {
271  reset();
272  }
273 
274  // Pointer-like operators
275 
277  X &operator* () const
278  {
279  return *pp;
280  }
281 
282  X *operator-> () const
283  {
284  return pp;
285  }
286 
287  void reset()
288  {
289  if (pp)
290  pp->~X(), pp = nullptr;
291  }
292 
293  // So you can say if(ptr)
294  explicit operator bool() const
295  {
296  return pp != nullptr;
297  }
298 
299  bool has_value() const
300  {
301  return pp != nullptr;
302  }
303 
304 private:
305  X* address()
306  {
307  return reinterpret_cast<X*>(&storage);
308  }
309 
310  // Data
311 #if 0
312  typename ::std::aligned_storage<
313  sizeof(X)
314  // , alignof(X) // Not here yet in all compilers
315  >::type storage{};
316 #else
317  union {
318  double d;
319  char storage[sizeof(X)];
320  };
321 #endif
322  X* pp{ nullptr };
323 };
324 
325 // Restore definition of debug new
326 #ifdef _DEBUG
327 #ifdef _MSC_VER
328 #undef THIS_FILE
329 static const char THIS_FILE[] = __FILE__;
330 #define new new(_NORMAL_BLOCK, THIS_FILE, __LINE__)
331 #endif
332 #endif
333 
337 struct freer { void operator() (void *p) const { free(p); } };
338 
342 template< typename T >
343 using MallocPtr = std::unique_ptr< T, freer >;
344 
348 template <typename Character = char>
349 using MallocString = std::unique_ptr< Character[], freer >;
350 
356 template <typename T>
357 struct Destroyer {
358  void operator () (T *p) const { if (p) p->Destroy(); }
359 };
360 
364 template <typename T>
365 using Destroy_ptr = std::unique_ptr<T, Destroyer<T>>;
366 
374 // Construct this from any copyable function object, such as a lambda
375 template <typename F>
376 struct Final_action {
377  Final_action(F f) : clean( f ) {}
379  F clean;
380 };
381 
384 template <typename F>
385 Final_action<F> finally (F f)
386 {
387  return Final_action<F>(f);
388 }
389 
390 #include <wx/utils.h> // for wxMin, wxMax
391 #include <algorithm>
392 
396 template< typename T >
397 struct RestoreValue {
399  void operator () ( T *p ) const { if (p) *p = oldValue; }
400 };
401 
402 
406 template< typename T >
407 class ValueRestorer : public std::unique_ptr< T, RestoreValue<T> >
408 {
409  using std::unique_ptr< T, RestoreValue<T> >::reset; // make private
410  // But release() remains public and can be useful to commit a changed value
411 public:
412  explicit ValueRestorer( T &var )
413  : std::unique_ptr< T, RestoreValue<T> >( &var, { var } )
414  {}
415  explicit ValueRestorer( T &var, const T& newValue )
416  : std::unique_ptr< T, RestoreValue<T> >( &var, { var } )
417  { var = newValue; }
419  : std::unique_ptr < T, RestoreValue<T> > ( std::move(that) ) {};
421  {
422  if (this != &that)
423  std::unique_ptr < T, RestoreValue<T> >::operator=(std::move(that));
424  return *this;
425  }
426 };
427 
429 template< typename T >
431 { return ValueRestorer< T >{ var }; }
432 
433 template< typename T >
434 ValueRestorer< T > valueRestorer( T& var, const T& newValue )
435 { return ValueRestorer< T >{ var, newValue }; }
436 
441 template< typename Value, typename Category = std::forward_iterator_tag >
442 using ValueIterator = std::iterator<
443  Category, const Value, ptrdiff_t,
444  // void pointer type so that operator -> is disabled
445  void,
446  // make "reference type" really the same as the value type
447  const Value
448 >;
449 
453 template <typename Iterator>
454 struct IteratorRange : public std::pair<Iterator, Iterator> {
455  using iterator = Iterator;
456  using reverse_iterator = std::reverse_iterator<Iterator>;
457 
458  IteratorRange (const Iterator &a, const Iterator &b)
459  : std::pair<Iterator, Iterator> ( a, b ) {}
460 
461  IteratorRange (Iterator &&a, Iterator &&b)
462  : std::pair<Iterator, Iterator> ( std::move(a), std::move(b) ) {}
463 
465  { return { this->rbegin(), this->rend() }; }
466 
467  Iterator begin() const { return this->first; }
468  Iterator end() const { return this->second; }
469 
470  reverse_iterator rbegin() const { return reverse_iterator{ this->second }; }
471  reverse_iterator rend() const { return reverse_iterator{ this->first }; }
472 
473  bool empty() const { return this->begin() == this->end(); }
474  explicit operator bool () const { return !this->empty(); }
475  size_t size() const { return std::distance(this->begin(), this->end()); }
476 
477  template <typename T> iterator find(const T &t) const
478  { return std::find(this->begin(), this->end(), t); }
479 
480  template <typename T> long index(const T &t) const
481  {
482  auto iter = this->find(t);
483  if (iter == this->end())
484  return -1;
485  return std::distance(this->begin(), iter);
486  }
487 
488  template <typename T> bool contains(const T &t) const
489  { return this->end() != this->find(t); }
490 
491  template <typename F> iterator find_if(const F &f) const
492  { return std::find_if(this->begin(), this->end(), f); }
493 
494  template <typename F> long index_if(const F &f) const
495  {
496  auto iter = this->find_if(f);
497  if (iter == this->end())
498  return -1;
499  return std::distance(this->begin(), iter);
500  }
501 
502  // to do: use std::all_of, any_of, none_of when available on all platforms
503  template <typename F> bool all_of(const F &f) const
504  {
505  auto notF =
506  [&](typename std::iterator_traits<Iterator>::reference v)
507  { return !f(v); };
508  return !this->any_of( notF );
509  }
510 
511  template <typename F> bool any_of(const F &f) const
512  { return this->end() != this->find_if(f); }
513 
514  template <typename F> bool none_of(const F &f) const
515  { return !this->any_of(f); }
516 
517  template<typename T> struct identity
518  { const T&& operator () (T &&v) const { return std::forward(v); } };
519 
520  // Like std::accumulate, but the iterators implied, and with another
521  // unary operation on the iterator value, pre-composed
522  template<
523  typename R,
524  typename Binary = std::plus< R >,
525  typename Unary = identity< decltype( *std::declval<Iterator>() ) >
526  >
528  R init,
529  Binary binary_op = {},
530  Unary unary_op = {}
531  ) const
532  {
533  R result = init;
534  for (auto&& v : *this)
535  result = binary_op(result, unary_op(v));
536  return result;
537  }
538 
539  // An overload making it more convenient to use with pointers to member
540  // functions
541  template<
542  typename R,
543  typename Binary = std::plus< R >,
544  typename R2, typename C
545  >
547  R init,
548  Binary binary_op,
549  R2 (C :: * pmf) () const
550  ) const
551  {
552  return this->accumulate( init, binary_op, std::mem_fn( pmf ) );
553  }
554 
555  // Some accumulations frequent enough to be worth abbreviation:
556  template<
557  typename Unary = identity< decltype( *std::declval<Iterator>() ) >,
558  typename R = decltype( std::declval<Unary>()( *std::declval<Iterator>() ) )
559  >
560  R min( Unary unary_op = {} ) const
561  {
562  return this->accumulate(
563  std::numeric_limits< R >::max(),
564  (const R&(*)(const R&, const R&)) std::min,
565  unary_op
566  );
567  }
568 
569  template<
570  typename R2, typename C,
571  typename R = R2
572  >
573  R min( R2 (C :: * pmf) () const ) const
574  {
575  return this->min( std::mem_fn( pmf ) );
576  }
577 
578  template<
579  typename Unary = identity< decltype( *std::declval<Iterator>() ) >,
580  typename R = decltype( std::declval<Unary>()( *std::declval<Iterator>() ) )
581  >
582  R max( Unary unary_op = {} ) const
583  {
584  return this->accumulate(
585  std::numeric_limits< R >::lowest(),
586  (const R&(*)(const R&, const R&)) std::max,
587  unary_op
588  );
589  }
590 
591  template<
592  typename R2, typename C,
593  typename R = R2
594  >
595  R max( R2 (C :: * pmf) () const ) const
596  {
597  return this->max( std::mem_fn( pmf ) );
598  }
599 
600  template<
601  typename Unary = identity< decltype( *std::declval<Iterator>() ) >,
602  typename R = decltype( std::declval<Unary>()( *std::declval<Iterator>() ) )
603  >
604  R sum( Unary unary_op = {} ) const
605  {
606  return this->accumulate(
607  R{ 0 },
608  std::plus< R >{},
609  unary_op
610  );
611  }
612 
613  template<
614  typename R2, typename C,
615  typename R = R2
616  >
617  R sum( R2 (C :: * pmf) () const ) const
618  {
619  return this->sum( std::mem_fn( pmf ) );
620  }
621 };
622 
623 template< typename Iterator>
625 make_iterator_range( const Iterator &i1, const Iterator &i2 )
626 {
627  return { i1, i2 };
628 }
629 
630 template< typename Container >
632 make_iterator_range( Container &container )
633 {
634  return { container.begin(), container.end() };
635 }
636 
637 template< typename Container >
639 make_iterator_range( const Container &container )
640 {
641  return { container.begin(), container.end() };
642 }
643 
644 // A utility function building a container of results
645 template< typename Container, typename Iterator, typename Function >
646 Container transform_range( Iterator first, Iterator last, Function &&fn )
647 {
648  Container result;
649  std::transform( first, last, std::back_inserter( result ), fn );
650  return result;
651 }
652 // A utility function, often constructing a vector from another vector
653 template< typename OutContainer, typename InContainer, typename Function >
654 OutContainer transform_container( InContainer &inContainer, Function &&fn )
655 {
656  return transform_range<OutContainer>(
657  inContainer.begin(), inContainer.end(), fn );
658 }
659 
660 // Extend wxArrayString with move operations and construction and insertion from
661 // std::initializer_list
662 class wxArrayStringEx : public wxArrayString
663 {
664 public:
665  using wxArrayString::wxArrayString;
666  wxArrayStringEx() = default;
667 
668  template< typename Iterator >
669  wxArrayStringEx( Iterator start, Iterator finish )
670  {
671  this->reserve( std::distance( start, finish ) );
672  while( start != finish )
673  this->push_back( *start++ );
674  }
675 
676  template< typename T >
677  wxArrayStringEx( std::initializer_list< T > items )
678  {
679  this->reserve( this->size() + items.size() );
680  for ( const auto &item : items )
681  this->push_back( item );
682  }
683 
684  // The move operations can take arguments of the base class wxArrayString
685  wxArrayStringEx( wxArrayString &&other )
686  {
687  swap( other );
688  }
689 
690  wxArrayStringEx &operator= ( wxArrayString &&other )
691  {
692  if ( this != &other ) {
693  clear();
694  swap( other );
695  }
696  return *this;
697  }
698 
699  using wxArrayString::insert;
700 
701  template< typename T >
702  iterator insert( const_iterator pos, std::initializer_list< T > items )
703  {
704  const auto index = pos - ((const wxArrayString*)this)->begin();
705  this->wxArrayString::Insert( {}, index, items.size() );
706  auto result = this->begin() + index, iter = result;
707  for ( auto pItem = items.begin(), pEnd = items.end();
708  pItem != pEnd;
709  ++pItem, ++iter
710  ) {
711  *iter = *pItem;
712  }
713  return result;
714  }
715 };
716 
717 // These macros are used widely, so declared here.
718 #define QUANTIZED_TIME(time, rate) (floor(((double)(time) * (rate)) + 0.5) / (rate))
719 // dB - linear amplitude conversions
720 #define DB_TO_LINEAR(x) (pow(10.0, (x) / 20.0))
721 #define LINEAR_TO_DB(x) (20.0 * log10(x))
722 
723 #define MAX_AUDIO (1. - 1./(1<<15))
724 
725 #endif // __AUDACITY_MEMORY_X_H__
IteratorRange::identity
Definition: MemoryX.h:518
transform_range
Container transform_range(Iterator first, Iterator last, Function &&fn)
Definition: MemoryX.h:646
Optional::emplace
X & emplace(Args &&... args)
Definition: MemoryX.h:259
IteratorRange::any_of
bool any_of(const F &f) const
Definition: MemoryX.h:511
std::__make_unique_result< X[]>::element
X element
Definition: MemoryX.h:45
Final_action::clean
F clean
Definition: MemoryX.h:379
Optional::Optional
Optional(const Optional &that)
Definition: MemoryX.h:219
Optional::Optional
Optional(Optional &&that)
Definition: MemoryX.h:236
valueRestorer
ValueRestorer< T > valueRestorer(T &var)
inline functions provide convenient parameter type deduction
Definition: MemoryX.h:430
ArraysOf::operator=
ArraysOf & operator=(ArraysOf &&that)
Definition: MemoryX.h:157
ArraysOf::ArraysOf
ArraysOf(Integral N)
Definition: MemoryX.h:141
make_iterator_range
IteratorRange< Iterator > make_iterator_range(const Iterator &i1, const Iterator &i2)
Definition: MemoryX.h:625
Optional
Like a smart pointer, allows for object to not exist (nullptr)
Definition: MemoryX.h:210
IteratorRange::max
R max(R2(C ::*pmf)() const) const
Definition: MemoryX.h:595
Optional::Optional
Optional()
Definition: MemoryX.h:216
std::make_unique
__make_unique_result< X >::scalar_case make_unique(Args &&... args)
Definition: MemoryX.h:51
fn
static const auto fn
Definition: WaveformView.cpp:1102
Final_action::Final_action
Final_action(F f)
Definition: MemoryX.h:377
ArraysOf::ArraysOf
ArraysOf()
Definition: MemoryX.h:138
ValueIterator
std::iterator< Category, const Value, ptrdiff_t, void, const Value > ValueIterator
A convenience for defining iterators that return rvalue types, so that they cooperate correctly with ...
Definition: MemoryX.h:448
CommandSignature
Class that maps parameter names to default values and validators.
Definition: CommandSignature.h:29
ArrayOf::reinit
void reinit(Integral count, bool initialize=false)
Definition: MemoryX.h:112
IteratorRange
A convenience for use with range-for.
Definition: MemoryX.h:454
Optional::address
X * address()
Definition: MemoryX.h:305
MallocString
std::unique_ptr< Character[], freer > MallocString
Definition: MemoryX.h:349
Final_action
"finally" as in The C++ Programming Language, 4th ed., p. 358 Useful for defining ad-hoc RAII actions...
Definition: MemoryX.h:376
RestoreValue::oldValue
T oldValue
Definition: MemoryX.h:398
IteratorRange::rend
reverse_iterator rend() const
Definition: MemoryX.h:471
Optional::storage
char storage[sizeof(X)]
Definition: MemoryX.h:319
ArraysOf::reinit
void reinit(Integral1 countN, Integral2 countM, bool initialize=false)
Definition: MemoryX.h:176
Destroyer
A deleter class to supply the second template parameter of unique_ptr for classes like wxWindow that ...
Definition: MemoryX.h:357
wxArrayStringEx::wxArrayStringEx
wxArrayStringEx(std::initializer_list< T > items)
Definition: MemoryX.h:677
transform_container
OutContainer transform_container(InContainer &inContainer, Function &&fn)
Definition: MemoryX.h:654
wxArrayStringEx::operator=
wxArrayStringEx & operator=(wxArrayString &&other)
Definition: MemoryX.h:690
Optional::has_value
bool has_value() const
Definition: MemoryX.h:299
wxArrayStringEx::wxArrayStringEx
wxArrayStringEx()=default
Optional::~Optional
~Optional()
Definition: MemoryX.h:269
IteratorRange::begin
Iterator begin() const
Definition: MemoryX.h:467
wxArrayStringEx
Definition: MemoryX.h:663
Optional::reset
void reset()
Definition: MemoryX.h:287
IteratorRange::min
R min(R2(C ::*pmf)() const) const
Definition: MemoryX.h:573
Optional::d
double d
Definition: MemoryX.h:318
IteratorRange::max
R max(Unary unary_op={}) const
Definition: MemoryX.h:582
ArraysOf::reinit
void reinit(Integral count)
Definition: MemoryX.h:164
IteratorRange::empty
bool empty() const
Definition: MemoryX.h:473
IteratorRange::iterator
Iterator iterator
Definition: MemoryX.h:455
ArrayOf::ArrayOf
ArrayOf()
Definition: MemoryX.h:84
std::__make_unique_result
Definition: MemoryX.h:38
IteratorRange::end
Iterator end() const
Definition: MemoryX.h:468
RestoreValue
Structure used by ValueRestorer.
Definition: MemoryX.h:397
std::__make_unique_result< X[]>::array_case
unique_ptr< X[]> array_case
Definition: MemoryX.h:44
ArraysOf::ArraysOf
ArraysOf(Integral1 N, Integral2 M, bool initialize=false)
Definition: MemoryX.h:146
ArraysOf
memory.h template class for making an array of arrays.
Definition: MemoryX.h:136
ArraysOf::reinit
void reinit(Integral count, bool initialize)
Definition: MemoryX.h:170
Destroyer::operator()
void operator()(T *p) const
Definition: MemoryX.h:358
RestoreValue::operator()
void operator()(T *p) const
Definition: MemoryX.h:399
IteratorRange::reverse_iterator
std::reverse_iterator< Iterator > reverse_iterator
Definition: MemoryX.h:456
ArrayOf::operator=
ArrayOf & operator=(ArrayOf &&that)
Definition: MemoryX.h:100
IteratorRange::identity::operator()
const T && operator()(T &&v) const
Definition: MemoryX.h:518
Optional::operator->
X * operator->() const
Definition: MemoryX.h:282
wxArrayStringEx::insert
iterator insert(const_iterator pos, std::initializer_list< T > items)
Definition: MemoryX.h:702
ValueRestorer::ValueRestorer
ValueRestorer(ValueRestorer &&that)
Definition: MemoryX.h:418
Optional::operator=
Optional & operator=(const Optional &that)
Definition: MemoryX.h:225
IteratorRange::index_if
long index_if(const F &f) const
Definition: MemoryX.h:494
ValueRestorer::ValueRestorer
ValueRestorer(T &var)
Definition: MemoryX.h:412
IteratorRange::all_of
bool all_of(const F &f) const
Definition: MemoryX.h:503
freer::operator()
void operator()(void *p) const
Definition: MemoryX.h:337
IteratorRange::find
iterator find(const T &t) const
Definition: MemoryX.h:477
wxArrayStringEx::wxArrayStringEx
wxArrayStringEx(wxArrayString &&other)
Definition: MemoryX.h:685
IteratorRange::reversal
IteratorRange< reverse_iterator > reversal() const
Definition: MemoryX.h:464
anonymous_namespace{NoteTrack.cpp}::swap
void swap(std::unique_ptr< Alg_seq > &a, std::unique_ptr< Alg_seq > &b)
Definition: NoteTrack.cpp:735
IteratorRange::IteratorRange
IteratorRange(Iterator &&a, Iterator &&b)
Definition: MemoryX.h:461
IteratorRange::sum
R sum(R2(C ::*pmf)() const) const
Definition: MemoryX.h:617
MallocPtr
std::unique_ptr< T, freer > MallocPtr
Definition: MemoryX.h:343
ArrayOf::ArrayOf
ArrayOf(ArrayOf &&that)
Definition: MemoryX.h:95
freer
Definition: MemoryX.h:337
wxArrayStringEx::wxArrayStringEx
wxArrayStringEx(Iterator start, Iterator finish)
Definition: MemoryX.h:669
IteratorRange::accumulate
R accumulate(R init, Binary binary_op, R2(C ::*pmf)() const) const
Definition: MemoryX.h:546
IteratorRange::rbegin
reverse_iterator rbegin() const
Definition: MemoryX.h:470
Final_action::~Final_action
~Final_action()
Definition: MemoryX.h:378
min
int min(int a, int b)
Definition: CompareAudioCommand.cpp:106
IteratorRange::contains
bool contains(const T &t) const
Definition: MemoryX.h:488
Optional::operator*
X & operator*() const
Dereference, with the usual bad consequences if NULL.
Definition: MemoryX.h:277
IteratorRange::min
R min(Unary unary_op={}) const
Definition: MemoryX.h:560
std::__make_unique_result::scalar_case
unique_ptr< X > scalar_case
Definition: MemoryX.h:39
ValueRestorer
Set a variable temporarily in a scope.
Definition: MemoryX.h:408
IteratorRange::accumulate
R accumulate(R init, Binary binary_op={}, Unary unary_op={}) const
Definition: MemoryX.h:527
IteratorRange::size
size_t size() const
Definition: MemoryX.h:475
ValueRestorer::ValueRestorer
ValueRestorer(T &var, const T &newValue)
Definition: MemoryX.h:415
ArrayOf::ArrayOf
ArrayOf(const ArrayOf &)=delete
Optional::pp
X * pp
Definition: MemoryX.h:322
IteratorRange::sum
R sum(Unary unary_op={}) const
Definition: MemoryX.h:604
Destroy_ptr
std::unique_ptr< T, Destroyer< T > > Destroy_ptr
a convenience for using Destroyer
Definition: MemoryX.h:365
safenew
#define safenew
Definition: MemoryX.h:8
ArrayOf::ArrayOf
ArrayOf(Integral count, bool initialize=false)
Definition: MemoryX.h:87
IteratorRange::IteratorRange
IteratorRange(const Iterator &a, const Iterator &b)
Definition: MemoryX.h:458
IteratorRange::index
long index(const T &t) const
Definition: MemoryX.h:480
ArrayOf
This simplifies arrays of arrays, each array separately allocated with NEW[] But it might be better t...
Definition: MemoryX.h:82
ArraysOf::ArraysOf
ArraysOf(const ArraysOf &)=delete
ValueRestorer::operator=
ValueRestorer & operator=(ValueRestorer &&that)
Definition: MemoryX.h:420
IteratorRange::find_if
iterator find_if(const F &f) const
Definition: MemoryX.h:491
IteratorRange::none_of
bool none_of(const F &f) const
Definition: MemoryX.h:514