1 // Copyright (c) 1999
2 // Utrecht University (The Netherlands),
3 // ETH Zurich (Switzerland),
4 // INRIA Sophia-Antipolis (France),
5 // Max-Planck-Institute Saarbruecken (Germany),
6 // and Tel-Aviv University (Israel).  All rights reserved.
7 //
8 // This file is part of CGAL (www.cgal.org)
9 //
10 // $URL: https://github.com/CGAL/cgal/blob/v5.3/STL_Extension/include/CGAL/tags.h $
11 // $Id: tags.h 8bb22d5 2020-03-26T14:23:37+01:00 Sébastien Loriot
12 // SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
13 //
14 //
15 // Author(s)     : Stefan Schirra
16 
17 
18 #ifndef CGAL_TAGS_H
19 #define CGAL_TAGS_H
20 
21 #include <CGAL/IO/io_tags.h>
22 #include <boost/mpl/integral_c.hpp>
23 
24 namespace CGAL {
25 
26 struct Void {};
27 
28 // Boolean_tag<bool> is a model of the Boost Integral Constant concept.
29 // https://www.boost.org/libs/mpl/doc/refmanual/integral-constant.html
30 template <bool b>
31 struct Boolean_tag {
32   typedef boost::mpl::integral_c_tag tag;
33   typedef bool value_type;
34   static const bool value = b;
35   typedef Boolean_tag<b> type;
36   operator bool() const { return this->value; }
37 };
38 /* In C++11, try:
39 template <bool b>
40 using Boolean_tag = std::integral_constant<bool, b>;
41 */
42 
43 typedef Boolean_tag<true>   Tag_true;
44 typedef Boolean_tag<false>  Tag_false;
45 
46 // the function check_tag is deprecated since CGAL 3.3
check_tag(Tag_true)47 inline bool check_tag( Tag_true)  {return true;}
check_tag(Tag_false)48 inline bool check_tag( Tag_false) {return false;}
49 
50 struct Null_tag {};
51 
52 struct Null_functor {
53   typedef Null_tag result_type;
54   typedef Null_tag second_argument_type;
55 };
56 
57 // For concurrency
58 struct Sequential_tag {};
59 struct Parallel_tag : public Sequential_tag {};
60 
61 #ifdef CGAL_LINKED_WITH_TBB
62 typedef CGAL::Parallel_tag Parallel_if_available_tag;
63 #else
64 typedef CGAL::Sequential_tag Parallel_if_available_tag;
65 #endif
66 
67 // A function that asserts a specific compile time tag
68 // forcing its two arguments to have equal type.
69 template <class Base>
70 struct Assert_tag_class
71 {
match_compile_time_tagAssert_tag_class72     void match_compile_time_tag( const Base&) const {}
73 };
74 
75 template <class Tag, class Derived>
76 inline
77 void
Assert_compile_time_tag(const Tag &,const Derived & b)78 Assert_compile_time_tag( const Tag&, const Derived& b)
79 {
80   Assert_tag_class<Tag> x;
81   x.match_compile_time_tag(b);
82 }
83 
84 } //namespace CGAL
85 
86 #endif // CGAL_TAGS_H
87