bitunion.hh (12465:db848583d43e) | bitunion.hh (12491:8765e1fb564d) |
---|---|
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; --- 17 unchanged lines hidden (view full) --- 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 * Authors: Gabe Black 29 */ 30 31#ifndef __BASE_BITUNION_HH__ 32#define __BASE_BITUNION_HH__ 33 | 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; --- 17 unchanged lines hidden (view full) --- 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 * Authors: Gabe Black 29 */ 30 31#ifndef __BASE_BITUNION_HH__ 32#define __BASE_BITUNION_HH__ 33 |
34#include <iostream> | 34#include <functional> |
35#include <type_traits> 36 37#include "base/bitfield.hh" 38 39// The following implements the BitUnion system of defining bitfields 40//on top of an underlying class. This is done through the pervasive use of 41//both named and unnamed unions which all contain the same actual storage. 42//Since they're unioned with each other, all of these storage locations --- 356 unchanged lines hidden (view full) --- 399template <typename T> 400using BitUnionBaseType = typename BitfieldBackend::BitUnionBaseType<T>::Type; 401 402 403//An STL style hash structure for hashing BitUnions based on their base type. 404namespace std 405{ 406 template <typename T> | 35#include <type_traits> 36 37#include "base/bitfield.hh" 38 39// The following implements the BitUnion system of defining bitfields 40//on top of an underlying class. This is done through the pervasive use of 41//both named and unnamed unions which all contain the same actual storage. 42//Since they're unioned with each other, all of these storage locations --- 356 unchanged lines hidden (view full) --- 399template <typename T> 400using BitUnionBaseType = typename BitfieldBackend::BitUnionBaseType<T>::Type; 401 402 403//An STL style hash structure for hashing BitUnions based on their base type. 404namespace std 405{ 406 template <typename T> |
407 struct hash; 408 409 template <typename T> | |
410 struct hash<BitUnionType<T> > : public hash<BitUnionBaseType<T> > 411 { 412 size_t 413 operator() (const BitUnionType<T> &val) const 414 { 415 return hash<BitUnionBaseType<T> >::operator()(val); 416 } 417 }; 418} 419 420#endif // __BASE_BITUNION_HH__ | 407 struct hash<BitUnionType<T> > : public hash<BitUnionBaseType<T> > 408 { 409 size_t 410 operator() (const BitUnionType<T> &val) const 411 { 412 return hash<BitUnionBaseType<T> >::operator()(val); 413 } 414 }; 415} 416 417#endif // __BASE_BITUNION_HH__ |