SeqAn3  3.0.3
The Modern C++ library for sequence analysis.
customisation_point.hpp
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------------------------------
2 // Copyright (c) 2006-2021, Knut Reinert & Freie Universität Berlin
3 // Copyright (c) 2016-2021, Knut Reinert & MPI für molekulare Genetik
4 // This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License
5 // shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md
6 // -----------------------------------------------------------------------------------------------------
7 
13 #pragma once
14 
15 #include <seqan3/core/platform.hpp>
16 
17 namespace seqan3::detail
18 {
19 
20 // ============================================================================
21 // priority_tag
22 // ============================================================================
23 
25 template <size_t I>
26 struct priority_tag
28 // Doxygen fail
29 : priority_tag<I-1>
31 {};
32 
34 template <>
35 struct priority_tag<0>
36 {};
37 
38 } // seqan3::detail
39 
40 // ============================================================================
41 // SEQAN3_CPO_IMPL
42 // ============================================================================
43 
46 #ifdef SEQAN3_DEPRECATED_310
47 #define SEQAN3_CPO_IMPL(PRIO, TERM) \
48  \
49 template <typename t, typename ...arg_ts> \
50 static constexpr decltype(auto) impl(seqan3::detail::priority_tag<PRIO>, \
51  [[maybe_unused]] t && v, \
52  [[maybe_unused]] arg_ts && ... args) \
53  noexcept(noexcept(TERM)) \
54  requires requires (seqan3::detail::priority_tag<PRIO> const &/*<- need for doxygen*/, t && v, arg_ts && ... args)\
55  { { TERM }; } \
56 { \
57  return TERM; \
58 }
59 #endif // SEQAN3_DEPRECATED_310
60 
61 #if SEQAN3_DOXYGEN_ONLY(1)0
76 #define SEQAN3_CPO_OVERLOAD_BODY(...) noexcept(auto) { return __VA_ARGS__; }
77 #else // ^^^ (simplified) doxygen version / normal definition vvv
78 #define SEQAN3_CPO_OVERLOAD_BODY(...) \
79  noexcept(noexcept(__VA_ARGS__)) \
80  -> decltype(__VA_ARGS__) \
81  { return __VA_ARGS__; } \
82  static_assert(true)
83 #endif
84 
113 #define SEQAN3_CPO_OVERLOAD(...) \
114  cpo_overload(__VA_ARGS__) \
115  SEQAN3_CPO_OVERLOAD_BODY
116 
117 namespace seqan3::detail
118 {
146 template <typename derived_t, unsigned max_priority>
147 struct customisation_point_object
148 {
149 private:
151  friend derived_t;
152 
153  constexpr customisation_point_object() = default;
154  constexpr customisation_point_object(customisation_point_object &&) = default;
155  constexpr customisation_point_object(customisation_point_object const &) = default;
156  constexpr customisation_point_object & operator=(customisation_point_object &&) = default;
157  constexpr customisation_point_object & operator=(customisation_point_object const &) = default;
158 
159 public:
170  template <typename ...args_t, typename derived_type = derived_t /*circumvent incomplete types*/>
171  constexpr auto operator()(args_t && ...args) const
173  (
174  /*return*/ derived_type::cpo_overload(priority_tag<max_priority>{}, std::forward<args_t>(args)...) /*;*/
175  );
176 };
177 } // namespace seqan3::detail
#define SEQAN3_CPO_OVERLOAD_BODY(...)
A macro helper for SEQAN3_CPO_OVERLOAD.
Definition: customisation_point.hpp:76
Provides platform and dependency checks.