mirror of https://github.com/CGAL/cgal
add partial specialization of Output_rep for optional and variant
This commit is contained in:
parent
11a5bfc84f
commit
84abdc7582
|
|
@ -32,6 +32,8 @@
|
|||
#include <string>
|
||||
#include <locale>
|
||||
#include <iostream>
|
||||
#include <optional>
|
||||
#include <variant>
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
|
|
@ -186,6 +188,30 @@ public:
|
|||
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
|
||||
\brief stream output of the \c Output_rep calls its \c operator().
|
||||
|
|
|
|||
Loading…
Reference in New Issue