3 /******************************************************************************
5 * Copyright (c) 2019 AT&T Intellectual Property.
6 * Copyright (c) 2018-2019 Nokia.
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
20 ******************************************************************************/
22 // Standard Includes: ANSI C/C++, MSA, and Third-Party Libraries
27 // Local Includes: Application specific classes, functions, and libraries
35 typedef variant<S> self_type;
38 static void check_size () {static_assert(sizeof (T) <= S, "wrong type");}
46 : typeinfo (&typeid (T))
61 typeinfo = & typeid (T);
62 return *new (as_<T>()) T;
70 typeinfo = & typeid (T);
71 return *new (as_<T> ()) T (t);
77 assert(*typeinfo == typeid (T));
85 assert(*typeinfo == typeid (T));
91 void swap(self_type& other)
94 assert (*typeinfo == *other.typeinfo);
95 std::swap (as<T> (), other.as<T> ());
99 void move(self_type& other)
106 template <typename T>
107 void copy(const self_type& other)
109 build<T> (other.as<T> ());
112 template <typename T>
120 self_type& operator=(const self_type&){}
121 variant (const self_type&){}
123 template <typename T>
126 void *p = buffer.raw;
127 return static_cast<T*> (p);
130 template <typename T>
133 const void *p = buffer.raw;
134 return static_cast<const T*> (p);
139 long double align_me;
143 const std::type_info *typeinfo;