#include <boost/config.hpp>
#ifdef BOOST_MSVC
# pragma warning(disable: 4512)
#endif
#include <boost/lexical_cast.hpp>
struct stringize_functor {
private:
std::string& result;
public:
explicit stringize_functor(std::string& res)
: result(res)
{}
template <class T>
void operator()(const T& v) const {
result += boost::lexical_cast<std::string>(v);
}
};
#include <boost/fusion/include/for_each.hpp>
template <class Sequence>
std::string stringize(const Sequence& seq) {
std::string result;
boost::fusion::for_each(seq, stringize_functor(result));
return result;
}
#include <boost/fusion/adapted/std_tuple.hpp>
#include <boost/fusion/adapted/std_pair.hpp>
int main() {
std::tuple<char, int, char, int> decim('-', 10, 'e', 5);
if (stringize(decim) != "-10e5") {
return 1;
}
std::pair<int, std::string> value_and_type(270, "Kelvin");
if (stringize(value_and_type) != "270Kelvin") {
return 2;
}
return 0;
}