1/*
2 * Copyright (c) 2007-2008 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 277 unchanged lines hidden (view full) ---

286//bitfield definitions which will end up inside it's union. As explained
287//above, these is overlayed the __storage member in its entirety by each of the
288//bitfields which are defined in the union, creating shared storage with no
289//overhead.
290#define __BitUnion(type, name) \
291 class BitfieldUnderlyingClasses##name : \
292 public BitfieldBackend::BitfieldTypes<type> \
293 { \
294 public: \
294 protected: \
295 typedef type __StorageType; \
296 friend BitfieldBackend::BitUnionBaseType< \
297 BitfieldBackend::BitUnionOperators< \
298 BitfieldUnderlyingClasses##name> >; \
299 friend BitfieldBackend::BitUnionBaseType< \
300 BitfieldUnderlyingClasses##name>; \
301 public: \
302 union { \
303 type __storage;
304
305//This closes off the class and union started by the above macro. It is
306//followed by a typedef which makes "name" refer to a BitfieldOperator
307//class inheriting from the class and union just defined, which completes
308//building up the type for the user.
309#define EndBitUnion(name) \

--- 79 unchanged lines hidden (view full) ---

389 {
390 typedef typename BitUnionType<T>::__StorageType Type;
391 };
392}
393
394template <typename T>
395using BitUnionBaseType = typename BitfieldBackend::BitUnionBaseType<T>::Type;
396
397
398//An STL style hash structure for hashing BitUnions based on their base type.
399namespace std
400{
401 template <typename T>
402 struct hash;
403
404 template <typename T>
405 struct hash<BitUnionType<T> > : public hash<BitUnionBaseType<T> >
406 {
407 size_t
408 operator() (const BitUnionType<T> &val) const
409 {
410 return hash<BitUnionBaseType<T> >::operator()(val);
411 }
412 };
413}
414
415#endif // __BASE_BITUNION_HH__