From b1465645adc0ac9b420d7fc5952b3b54b1f4dc08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 29 Jun 2023 18:48:15 +0200 Subject: [PATCH] fix variant output --- Stream_support/include/CGAL/IO/io.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Stream_support/include/CGAL/IO/io.h b/Stream_support/include/CGAL/IO/io.h index 3460398bea9..6a5fa185e6b 100644 --- a/Stream_support/include/CGAL/IO/io.h +++ b/Stream_support/include/CGAL/IO/io.h @@ -191,13 +191,15 @@ public: template class Output_rep, F> { - const std::optional& t; + const std::optional& t; public: Output_rep( const std::optional& tt) : t(tt) {} - std::ostream& operator()( std::ostream& os) const { + std::ostream& operator()( std::ostream& os) const + { if (t==std::nullopt) return (os << "--"); - return (os << t.value()); } + return (os << t.value()); + } }; template @@ -207,8 +209,10 @@ class Output_rep, F> public: Output_rep( const std::variant& tt) : t(tt) {} - std::ostream& operator()( std::ostream& os) const { - return (os << "--"); + std::ostream& operator()( std::ostream& os) const + { + std::visit([&os](auto&& v) { os << v; }, t); + return os; } };