#include <iostream>
#include <boost/mpl/pair.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/sort.hpp>
#include <boost/mpl/for_each.hpp>
using namespace boost;
template <int V, int P>
using Value = mpl::pair<mpl::int_<V>, mpl::int_<P> >;
typedef mpl::vector<Value<3, 12>, Value<5, 1>, Value<0, 16> >::type RawData;
typedef mpl::sort<RawData, mpl::less<mpl::first<mpl::_1>, mpl::first<mpl::_2> > >::type SortedData;
struct Printer {
template<typename T> void operator()(T) {
std::cout << mpl::first<T>::type::value << ": " << mpl::second<T>::type::value << std::endl;
}
};
int main() {
std::cout << "Raw: " << std::endl;
mpl::for_each<RawData>(Printer());
std::cout << "Sorted: " << std::endl;
mpl::for_each<SortedData>(Printer());
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKI2luY2x1ZGUgPGJvb3N0L21wbC9wYWlyLmhwcD4KI2luY2x1ZGUgPGJvb3N0L21wbC92ZWN0b3IuaHBwPgojaW5jbHVkZSA8Ym9vc3QvbXBsL3NvcnQuaHBwPgojaW5jbHVkZSA8Ym9vc3QvbXBsL2Zvcl9lYWNoLmhwcD4KCnVzaW5nIG5hbWVzcGFjZSBib29zdDsKCnRlbXBsYXRlIDxpbnQgViwgaW50IFA+CnVzaW5nIFZhbHVlID0gbXBsOjpwYWlyPG1wbDo6aW50XzxWPiwgbXBsOjppbnRfPFA+ID47Cgp0eXBlZGVmIG1wbDo6dmVjdG9yPFZhbHVlPDMsIDEyPiwgVmFsdWU8NSwgMT4sIFZhbHVlPDAsIDE2PiA+Ojp0eXBlIFJhd0RhdGE7CnR5cGVkZWYgbXBsOjpzb3J0PFJhd0RhdGEsIG1wbDo6bGVzczxtcGw6OmZpcnN0PG1wbDo6XzE+LCBtcGw6OmZpcnN0PG1wbDo6XzI+ID4gPjo6dHlwZSBTb3J0ZWREYXRhOwoKc3RydWN0IFByaW50ZXIgewogIHRlbXBsYXRlPHR5cGVuYW1lIFQ+IHZvaWQgb3BlcmF0b3IoKShUKSB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