SeqAn3  3.1.0-rc.1
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 
26 template <size_t I>
27 struct priority_tag
29 // Doxygen fail
30 : priority_tag<I-1>
32 {};
33 
35 template <>
36 struct priority_tag<0>
37 {};
38 
39 } // seqan3::detail
40 
41 // ============================================================================
42 // SEQAN3_CPO_OVERLOAD
43 // ============================================================================
44 #if SEQAN3_DOXYGEN_ONLY(1)0
62 #define SEQAN3_CPO_OVERLOAD_BODY(...) noexcept(auto) { return __VA_ARGS__; }
63 #else // ^^^ (simplified) doxygen version / normal definition vvv
64 #define SEQAN3_CPO_OVERLOAD_BODY(...) \
65  noexcept(noexcept(__VA_ARGS__)) \
66  -> decltype(__VA_ARGS__) \
67  { return __VA_ARGS__; } \
68  static_assert(true)
69 #endif
70 
102 #define SEQAN3_CPO_OVERLOAD(...) \
103  cpo_overload(__VA_ARGS__) \
104  SEQAN3_CPO_OVERLOAD_BODY
105 
106 namespace seqan3::detail
107 {
136 template <typename derived_t, unsigned max_priority>
137 struct customisation_point_object
138 {
139 private:
141  friend derived_t;
142 
143  constexpr customisation_point_object() = default;
144  constexpr customisation_point_object(customisation_point_object &&) = default;
145  constexpr customisation_point_object(customisation_point_object const &) = default;
146  constexpr customisation_point_object & operator=(customisation_point_object &&) = default;
147  constexpr customisation_point_object & operator=(customisation_point_object const &) = default;
148 
149 public:
160  template <typename ...args_t, typename derived_type = derived_t /*circumvent incomplete types*/>
161  constexpr auto operator()(args_t && ...args) const
163  (
164  /*return*/ derived_type::cpo_overload(priority_tag<max_priority>{}, std::forward<args_t>(args)...) /*;*/
165  );
166 };
167 } // namespace seqan3::detail
#define SEQAN3_CPO_OVERLOAD_BODY(...)
A macro helper for SEQAN3_CPO_OVERLOAD.
Definition: customisation_point.hpp:62
Provides platform and dependency checks.