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