opennurbs_private_wrap_defs.h
1 /* $NoKeywords: $ */
2 /*
3 //
4 // Copyright (c) 1993-2014 Robert McNeel & Associates. All rights reserved.
5 // OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert
6 // McNeel & Associates.
7 //
8 // THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
9 // ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
10 // MERCHANTABILITY ARE HEREBY DISCLAIMED.
11 //
12 // For complete openNURBS copyright information see <http://www.opennurbs.org>.
13 //
14 ////////////////////////////////////////////////////////////////
15 */
16 #if !defined(OPENNURBS_PRIVATE_WRAP_DEFS_INC_)
17 #define OPENNURBS_PRIVATE_WRAP_DEFS_INC_
18 
19 #if 0
20 // OBSOLETE
21 template <class T>
22 ON_PrivateWrap<T>::ON_PrivateWrap()
23  : r(*(new(((void*)_buffer))T()))
24 {
25  // Use placement new to constuct a T class in the memory located in the _buffer[] member;
26 }
27 
28 template <class T >
29 ON_PrivateWrap< T >::~ON_PrivateWrap()
30 {
31  T * p = &r;
32  if (nullptr != p)
33  p->~T();
34  _buffer[0] = _buffer[1] = _buffer[2] = _buffer[3] = _buffer[4] = 0;
35 }
36 
37 template <class T >
38 ON_PrivateWrap< T >::ON_PrivateWrap(const ON_PrivateWrap< T >& src)
39  : r(*(new(((void*)_buffer))T(src.r)))
40 {
41  // Use in placement new to copy constuct a T class in the memory located in the _buffer[] member;
42 }
43 
44 template <class T >
45 ON_PrivateWrap< T >& ON_PrivateWrap< T >::operator=(const ON_PrivateWrap< T >& src)
46 {
47  if (this != &src)
48  r = src.r;
49  return *this;
50 }
51 
52 template <class T >
53 ON_PrivateWrap< T >::ON_PrivateWrap(const ON_PrivateWrap< T >&& src)
54  : r(*(new(((void*)_buffer))T(std::move(src.r))))
55 {
56  // Use in placement new to rvalue copy constuct a T class in the memory located in the _buffer[] member;
57 }
58 
59 template <class T >
60 ON_PrivateWrap< T >& ON_PrivateWrap< T >::operator=(const ON_PrivateWrap< T >&& src)
61 {
62  if (this != &src)
63  r = std::move(src.r);
64  return *this;
65 }
66 
67 template <class T >
68 ON_PrivateWrap< T >::operator const T * () const
69 {
70  return &r;
71 }
72 
73 template <class T >
74 ON_PrivateWrap< T >::operator T * ()
75 {
76  return &r;
77 }
78 
79 template <class T >
80 ON_PrivateWrap< T >::operator const T & () const
81 {
82  return r;
83 }
84 
85 template <class T >
86 ON_PrivateWrap< T >::operator T& ()
87 {
88  return r;
89 }
90 #endif
91 
92 #endif
93