K
KevinSimonson
Can someone tell me what the following code does? The first
"template<typename T, Endianess endianPolicy> struct TransformTo"
makes sense to me, but I don't understand what the "template<typename
T > struct TransformTo< T, Machine::endianess>" does. Also, in the
first one "endianPolicy" is mentioned but never used. So does that
mean including it has no effect? I'm kind of confused on that.
//! \brief Generic function object to give its char serialization a
given
//! specified byte ordering.
//!
//! The byte ordering of the argument is swapped unless it matches the
byte
//! ordering of the target machine.
//! We use partial specialization to achieve this.
template<typename T, Endianess endianPolicy> struct TransformTo
{
T operator()(T value) const { return swapEndianess< T >( value ); }
};
template<typename T > struct TransformTo< T, Machine::endianess >
{
T operator()(T value) const { return value; }
};
Kevin S
"template<typename T, Endianess endianPolicy> struct TransformTo"
makes sense to me, but I don't understand what the "template<typename
T > struct TransformTo< T, Machine::endianess>" does. Also, in the
first one "endianPolicy" is mentioned but never used. So does that
mean including it has no effect? I'm kind of confused on that.
//! \brief Generic function object to give its char serialization a
given
//! specified byte ordering.
//!
//! The byte ordering of the argument is swapped unless it matches the
byte
//! ordering of the target machine.
//! We use partial specialization to achieve this.
template<typename T, Endianess endianPolicy> struct TransformTo
{
T operator()(T value) const { return swapEndianess< T >( value ); }
};
template<typename T > struct TransformTo< T, Machine::endianess >
{
T operator()(T value) const { return value; }
};
Kevin S