diff --git a/SMDS_3/include/CGAL/Simplicial_mesh_vertex_base_3.h b/SMDS_3/include/CGAL/Simplicial_mesh_vertex_base_3.h index 04b6f19af18..24656da85e1 100644 --- a/SMDS_3/include/CGAL/Simplicial_mesh_vertex_base_3.h +++ b/SMDS_3/include/CGAL/Simplicial_mesh_vertex_base_3.h @@ -26,9 +26,9 @@ #include #include +#include #include -#include #include namespace CGAL { @@ -53,7 +53,7 @@ public: using Vertex_handle = typename Vb::Vertex_handle; // Types - using Index = std::variant; + using Index = Variant_with_no_duplicate_t; using FT = typename GT::FT; // Constructor diff --git a/STL_Extension/include/CGAL/variant.h b/STL_Extension/include/CGAL/variant.h new file mode 100644 index 00000000000..41bd836d8cc --- /dev/null +++ b/STL_Extension/include/CGAL/variant.h @@ -0,0 +1,87 @@ +// Copyright (c) 2023 GeometryFactory Sarl (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org) +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// +// Author(s) : Sébastien Loriot +// + +#ifndef CGAL_VARIANT_H +#define CGAL_VARIANT_H + +#include + +namespace CGAL +{ + +template +struct Is_in_variant; + +template +struct Is_in_variant> +{ + inline static constexpr bool value = + std::is_same_v || Is_in_variant>::value; +}; + +template +struct Is_in_variant> +{ + inline static constexpr bool value = std::is_same_v; +}; + +/// equals true iif `T` is a possible type in `Variant` with `Variant` being a `std::variant` +template +inline constexpr bool Is_in_variant_v = Is_in_variant::value; + +// -- +template +struct Add_to_variant; + +template +struct Add_to_variant> +{ + using type = std::variant; +}; + +/// a `std::variant` with `T` appended to the types of the `std::variant` `Variant` +template< class T, class Variant > +using Add_to_variant_t = typename Add_to_variant::type; + +namespace internal{ +template +struct Get_variant_impl +{ + using type = typename Get_variant_impl< + std::conditional_t, + Variant, + Add_to_variant_t>, + Tn...>::type; +}; + +template +struct Get_variant_impl +{ + using type = std::conditional_t, + Variant, + Add_to_variant_t>; +}; +} // end of internal namespace + +template +struct Variant_with_no_duplicate +{ + using type = typename internal::Get_variant_impl, Tn ...>::type; +}; + +/// a `std::variant` with types being all different +template< class ... Tn > +using Variant_with_no_duplicate_t = typename Variant_with_no_duplicate::type; + +} //end of CGAL namespace + +#endif