Sequoia
Loading...
Searching...
No Matches
Preprocessor.hpp
1
2// Copyright Oliver J. Rosten 2020. //
3// Distributed under the GNU GENERAL PUBLIC LICENSE, Version 3.0. //
4// (See accompanying file LICENSE.md or copy at //
5// https://www.gnu.org/licenses/gpl-3.0.en.html) //
7
8#pragma once
9
13
14#include <execution>
15#include <vector>
16
17namespace sequoia
18{
19
20 #if defined(_MSC_VER)
21 using compiler_constant = msvc_type;
22
23 [[nodiscard]]
24 constexpr int iterator_debug_level() noexcept
25 {
26 return _ITERATOR_DEBUG_LEVEL;
27 }
28
29 #define SEQUOIA_MSVC_EMPTY_BASE_HACK __declspec(empty_bases)
30
31 #define SEQUOIA_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]]
32 #else
33 #if defined(__clang__)
34 using compiler_constant = clang_type;
35 #elif defined(__GNUG__)
36 using compiler_constant = gcc_type;
37 #else
38 using compiler_constant = other_compiler_type;
39 #endif
40
41 int iterator_debug_level() noexcept;
42
43 #define SEQUOIA_MSVC_EMPTY_BASE_HACK
44
45 #define SEQUOIA_NO_UNIQUE_ADDRESS [[no_unique_address]]
46 #endif
47
48 #if defined(__clang__)
49 namespace execution
50 {
51 inline constexpr int par{0};
52 }
53 #else
54 namespace execution
55 {
56 inline constexpr auto par{std::execution::par};
57 }
58 #endif
59
60 inline constexpr bool with_msvc_v{std::is_same_v<compiler_constant, msvc_type>};
61 inline constexpr bool with_clang_v{std::is_same_v<compiler_constant, clang_type>};
62 inline constexpr bool with_gcc_v{std::is_same_v<compiler_constant, gcc_type>};
63}
Types to descriminate different compilers.