/* @file concat.hpp */ #pragma once #include "ppdetail_atomic.hpp" #include #include // for std::move() namespace xo { template struct concat_impl { public: concat_impl(T1 && x1, T2 && x2) : x1_{std::forward(x1)}, x2_{std::forward(x2)} {} T1 const & x1() const { return x1_; } T2 const & x2() const { return x2_; } private: T1 x1_; T2 x2_; }; /*concat_impl*/ template T1 concat(T1 && x1) { return x1; } /*concat*/ template concat_impl concat(T1 && x1, T2 && x2) { return concat_impl(std::move(x1), std::move(x2)); } /*concat*/ template inline std::ostream & operator<<(std::ostream & os, concat_impl const & x) { os << x.x1() << x.x2(); return os; } /*operator<<*/ #ifndef ppdetail_atomic namespace print { /* concat expected to be used on short string-like things. * i.e. don't want structure visible to pretty-printer. * could be using it like concat("boeing", 777) */ template struct ppdetail> { using target_type = concat_impl; static bool print_pretty(const ppindentinfo & ppii, const target_type & x) { return ppdetail_atomic::print_pretty(ppii, x); } }; } #endif } /*namespace xo*/ /* end concat.hpp */