
27 May
2010
27 May
'10
2:32 p.m.
On May 27, 2010, at 9:10 AM, Stewart, Robert wrote:
Here's another take on the interface:
template <class T, class U> void from_big_endian(T &, U);
[... snip several more ...] template <class T, class U> T little_endian_cast(U);
Obviously, I've embedded the direction and ordering in the function template names rather than in a template argument, but that looks more readable to me.
What about various flavors of mixed / middle endian? Some of them actually do appear in the wild, which leads me to prefer the template argument approach to a potential proliferation of function names. The template argument approach also might be easier to work with in generic code.