Michele De Stefano's C++ Utilities
test_endian.cpp

This is an example on how to use C++ classes to test machine endianity.

// test_endian.cpp
//
// Copyright (c) 2009 - Michele De Stefano (micdestefano@users.sourceforge.net)
//
// Distributed under the MIT License (See accompanying file LICENSE)
#include <iostream>
using namespace std;
using namespace mds_utils;
template<class IsEndian>
void print_endianity();
template<>
void print_endianity<boost::mpl::true_>() {
cout << "\nLittle Endian machine !!!\n" << endl;
}
template<>
void print_endianity<boost::mpl::false_>() {
cout << "\nBig Endian machine !!!\n" << endl;
}
int main() {
print_endianity<little_endian_machine::type>();
return EXIT_SUCCESS;
}