add partial specialization of Output_rep for optional and variant

This commit is contained in:
Sébastien Loriot 2023-06-29 10:43:21 +02:00
parent 11a5bfc84f
commit 84abdc7582
1 changed files with 26 additions and 0 deletions

View File

@ -32,6 +32,8 @@
#include <string> #include <string>
#include <locale> #include <locale>
#include <iostream> #include <iostream>
#include <optional>
#include <variant>
namespace CGAL { namespace CGAL {
@ -186,6 +188,30 @@ public:
std::ostream& operator()( std::ostream& os) const { return (os << t); } std::ostream& operator()( std::ostream& os) const { return (os << t); }
}; };
template <class T, class F>
class Output_rep<std::optional<T>, F>
{
const std::optional<T>& t;
public:
Output_rep( const std::optional<T>& tt) : t(tt) {}
std::ostream& operator()( std::ostream& os) const {
if (t==std::nullopt) return (os << "--");
return (os << t.value()); }
};
template <class ... T, class F>
class Output_rep<std::variant<T...>, F>
{
const std::variant<T...>& t;
public:
Output_rep( const std::variant<T...>& tt) : t(tt) {}
std::ostream& operator()( std::ostream& os) const {
return (os << "--");
}
};
/*! /*!
\relates Output_rep \relates Output_rep
\brief stream output of the \c Output_rep calls its \c operator(). \brief stream output of the \c Output_rep calls its \c operator().