@@ -147,44 +147,44 @@ struct value
147147# undef CRUDE_MAX4
148148# undef CRUDE_MAX3
149149# undef CRUDE_MAX2
150- using storage_t = std::aligned_storage< max_size, max_align>::type ;
151-
152- static object* object_ptr ( storage_t & storage) { return reinterpret_cast < object*>(& storage); }
153- static const object* object_ptr (const storage_t & storage) { return reinterpret_cast <const object*>(& storage); }
154- static array* array_ptr ( storage_t & storage) { return reinterpret_cast < array*>(& storage); }
155- static const array* array_ptr (const storage_t & storage) { return reinterpret_cast <const array*>(& storage); }
156- static string* string_ptr ( storage_t & storage) { return reinterpret_cast < string*>(& storage); }
157- static const string* string_ptr (const storage_t & storage) { return reinterpret_cast <const string*>(& storage); }
158- static boolean* boolean_ptr ( storage_t & storage) { return reinterpret_cast < boolean*>(& storage); }
159- static const boolean* boolean_ptr (const storage_t & storage) { return reinterpret_cast <const boolean*>(& storage); }
160- static number* number_ptr ( storage_t & storage) { return reinterpret_cast < number*>(& storage); }
161- static const number* number_ptr (const storage_t & storage) { return reinterpret_cast <const number*>(& storage); }
150+ struct storage_t { alignas (max_align) unsigned char data[ max_size]; } ;
151+
152+ static object* object_ptr ( storage_t & storage) { return reinterpret_cast < object*>(storage. data ); }
153+ static const object* object_ptr (const storage_t & storage) { return reinterpret_cast <const object*>(storage. data ); }
154+ static array* array_ptr ( storage_t & storage) { return reinterpret_cast < array*>(storage. data ); }
155+ static const array* array_ptr (const storage_t & storage) { return reinterpret_cast <const array*>(storage. data ); }
156+ static string* string_ptr ( storage_t & storage) { return reinterpret_cast < string*>(storage. data ); }
157+ static const string* string_ptr (const storage_t & storage) { return reinterpret_cast <const string*>(storage. data ); }
158+ static boolean* boolean_ptr ( storage_t & storage) { return reinterpret_cast < boolean*>(storage. data ); }
159+ static const boolean* boolean_ptr (const storage_t & storage) { return reinterpret_cast <const boolean*>(storage. data ); }
160+ static number* number_ptr ( storage_t & storage) { return reinterpret_cast < number*>(storage. data ); }
161+ static const number* number_ptr (const storage_t & storage) { return reinterpret_cast <const number*>(storage. data ); }
162162
163163 static type_t construct (storage_t & storage, type_t type)
164164 {
165165 switch (type)
166166 {
167- case type_t ::object: new (& storage) object (); break ;
168- case type_t ::array: new (& storage) array (); break ;
169- case type_t ::string: new (& storage) string (); break ;
170- case type_t ::boolean: new (& storage) boolean (); break ;
171- case type_t ::number: new (& storage) number (); break ;
167+ case type_t ::object: new (storage. data ) object (); break ;
168+ case type_t ::array: new (storage. data ) array (); break ;
169+ case type_t ::string: new (storage. data ) string (); break ;
170+ case type_t ::boolean: new (storage. data ) boolean (); break ;
171+ case type_t ::number: new (storage. data ) number (); break ;
172172 default : break ;
173173 }
174174
175175 return type;
176176 }
177177
178178 static type_t construct (storage_t & storage, null) { (void )storage; return type_t ::null; }
179- static type_t construct (storage_t & storage, object&& value) { new (& storage) object (std::forward<object>(value)); return type_t ::object; }
180- static type_t construct (storage_t & storage, const object& value) { new (& storage) object (value); return type_t ::object; }
181- static type_t construct (storage_t & storage, array&& value) { new (& storage) array (std::forward<array>(value)); return type_t ::array; }
182- static type_t construct (storage_t & storage, const array& value) { new (& storage) array (value); return type_t ::array; }
183- static type_t construct (storage_t & storage, string&& value) { new (& storage) string (std::forward<string>(value)); return type_t ::string; }
184- static type_t construct (storage_t & storage, const string& value) { new (& storage) string (value); return type_t ::string; }
185- static type_t construct (storage_t & storage, const char * value) { new (& storage) string (value); return type_t ::string; }
186- static type_t construct (storage_t & storage, boolean value) { new (& storage) boolean (value); return type_t ::boolean; }
187- static type_t construct (storage_t & storage, number value) { new (& storage) number (value); return type_t ::number; }
179+ static type_t construct (storage_t & storage, object&& value) { new (storage. data ) object (std::forward<object>(value)); return type_t ::object; }
180+ static type_t construct (storage_t & storage, const object& value) { new (storage. data ) object (value); return type_t ::object; }
181+ static type_t construct (storage_t & storage, array&& value) { new (storage. data ) array (std::forward<array>(value)); return type_t ::array; }
182+ static type_t construct (storage_t & storage, const array& value) { new (storage. data ) array (value); return type_t ::array; }
183+ static type_t construct (storage_t & storage, string&& value) { new (storage. data ) string (std::forward<string>(value)); return type_t ::string; }
184+ static type_t construct (storage_t & storage, const string& value) { new (storage. data ) string (value); return type_t ::string; }
185+ static type_t construct (storage_t & storage, const char * value) { new (storage. data ) string (value); return type_t ::string; }
186+ static type_t construct (storage_t & storage, boolean value) { new (storage. data ) boolean (value); return type_t ::boolean; }
187+ static type_t construct (storage_t & storage, number value) { new (storage. data ) number (value); return type_t ::number; }
188188
189189 static void destruct (storage_t & storage, type_t type)
190190 {
0 commit comments