Deleted Added
sdiff udiff text old ( 12625:c0cf272e0456 ) new ( 12631:d48fc4cce6eb )
full compact
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;

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

414 return hash<BitUnionBaseType<T> >::operator()(val);
415 }
416 };
417}
418
419
420namespace BitfieldBackend
421{
422
423 template<typename T>
424 static inline std::ostream &
425 bitfieldBackendPrinter(std::ostream &os, const T &t)
426 {
427 os << t;
428 return os;
429 }
430
431 //Since BitUnions are generally numerical values and not character codes,
432 //these specializations attempt to ensure that they get cast to integers
433 //of the appropriate type before printing.
434 template <>
435 inline std::ostream &
436 bitfieldBackendPrinter(std::ostream &os, const char &t)
437 {
438 os << (const int)t;
439 return os;
440 }
441
442 template <>
443 inline std::ostream &
444 bitfieldBackendPrinter(std::ostream &os, const unsigned char &t)
445 {
446 os << (const unsigned int)t;
447 return os;
448 }
449}
450
451//A default << operator which casts a bitunion to its underlying type and
452//passes it to BitfieldBackend::bitfieldBackendPrinter.
453template <typename T>
454std::ostream &
455operator << (std::ostream &os, const BitUnionType<T> &bu)
456{
457 return BitfieldBackend::bitfieldBackendPrinter(
458 os, (BitUnionBaseType<T>)bu);
459}
460
461#endif // __BASE_BITUNION_HH__