// // gtest_variant_printers.h // variant // // Created by Sam Jaffe on 8/14/20. // Copyright © 2020 Sam Jaffe. All rights reserved. // #pragma once template std::ostream & operator<<(std::ostream & os, std::map const & value) { os << "{"; if (value.size()) { auto it = value.cbegin(); os << " " << it->first << ":" << it->second; for (++it; it != value.cend(); ++it) { os << ", " << it->first << ":" << it->second; } } return os << " }"; } template void PrintTo(variant const & value, std::ostream * os) { if (value.index() == I) { (*os) << value.template get(); } } template void PrintTo(variant const & value, std::ostream * os, std::index_sequence) { [[maybe_unused]] auto l = {(PrintTo(value, os), 0)...}; } template void PrintTo(variant const & value, std::ostream * os) { if (value.valid()) { PrintTo(value, os, std::make_index_sequence()); } else { (*os) << ""; } }