3 /*-------------------------------------------------------------------------
4 * drawElements Quality Program Tester Core
5 * ----------------------------------------
7 * Copyright 2015 The Android Open Source Project
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
23 * \brief Template for values that may not exist.
24 *//*--------------------------------------------------------------------*/
26 #include "tcuDefs.hpp"
31 // \note Type T is always aligned to same alignment as deUint64.
32 // \note This type always uses at least sizeof(T*) + sizeof(deUint64) of memory.
41 Maybe<T>& operator= (const T& val);
43 Maybe (const Maybe<T>& other);
44 Maybe<T>& operator= (const Maybe<T>& other);
46 const T& get (void) const;
47 const T& operator* (void) const { return get(); }
49 const T* operator-> (void) const;
50 operator bool (void) const { return m_ptr; }
57 deUint8 m_data[sizeof(T)];
63 Maybe<T> nothing (void)
69 Maybe<T>::Maybe (void)
75 Maybe<T>::~Maybe (void)
82 Maybe<T>::Maybe (const T& val)
85 m_ptr = new(m_data)T(val);
89 Maybe<T>& Maybe<T>::operator= (const T& val)
94 m_ptr = new(m_data)T(val);
100 Maybe<T>::Maybe (const Maybe<T>& other)
104 m_ptr = new(m_data)T(*other.m_ptr);
108 Maybe<T>& Maybe<T>::operator= (const Maybe<T>& other)
117 m_ptr = new(m_data)T(*other.m_ptr);
125 const T* Maybe<T>::operator-> (void) const
132 const T& Maybe<T>::get (void) const
140 #endif // _TCUMAYBE_HPP