helics 3.7.0
Loading...
Searching...
No Matches
config.hpp
1/*
2Copyright (c) 2017-2026,
3Battelle Memorial Institute; Lawrence Livermore National Security, LLC; Alliance for Energy
4Innovation LLC. See the top-level NOTICE for additional details. All rights reserved.
5SPDX-License-Identifier: BSD-3-Clause
6*/
7#ifndef HELICS_CPP98_CONFIG_HPP_
8#define HELICS_CPP98_CONFIG_HPP_
9#pragma once
10
11// Detect whether the compiler supports C++11 rvalue references.
12#if (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 2)) && \
13 defined(__GXX_EXPERIMENTAL_CXX0X__))
14# define HELICS_HAS_RVALUE_REFS
15#elif defined(__clang__)
16# if __has_feature(cxx_rvalue_references)
17# define HELICS_HAS_RVALUE_REFS
18# endif
19#elif defined(_MSC_VER) && (_MSC_VER >= 1900)
20# define HELICS_HAS_RVALUE_REFS
21#elif defined(_MSC_VER) && (_MSC_VER >= 1600)
22# define HELICS_HAS_RVALUE_REFS
23#endif
24
25// Detect whether the compiler supports C++11.
26#if __cplusplus > 199711L
27# define HELICS_THROWS_EXCEPTION noexcept(false)
28# define HELICS_NOTHROW noexcept
29# define HELICS_NULL_POINTER nullptr
30# define HELICS_HAS_FUNCTIONAL 1
31#elif defined(_MSC_VER) && (_MSC_VER >= 1900)
32# define HELICS_THROWS_EXCEPTION noexcept(false)
33# define HELICS_NOTHROW noexcept
34# define HELICS_NULL_POINTER nullptr
35# define HELICS_HAS_FUNCTIONAL 1
36#else
37# define HELICS_THROWS_EXCEPTION throw(HelicsException)
38# define HELICS_NOTHROW throw()
39# define HELICS_NULL_POINTER NULL
40# define HELICS_HAS_FUNCTIONAL 0
41#endif
42
43#define HELICS_IGNORE_ERROR HELICS_NULL_POINTER
44
45// The following sequence is derived from similar code in CLI11
46#if !(defined(_MSC_VER) && __cplusplus == 199711L) && !defined(__INTEL_COMPILER)
47# if __cplusplus >= 201703L
48# define HELICS_CPP17
49# endif
50#elif defined(_MSC_VER) && __cplusplus == 199711L
51// MSVC sets _MSVC_LANG rather than __cplusplus (supposedly until the standard was fully
52// implemented) Unless you use the /Zc:__cplusplus flag on Visual Studio 2017 15.7 Preview 3 or
53// newer
54# if _MSVC_LANG > 201402L && _MSC_VER >= 1910
55# define HELICS_CPP17
56# endif
57#endif
58
59// GCC < 10 doesn't ignore this in unevaluated contexts
60#if !defined(HELICS_CPP17) || \
61 (defined(__GNUC__) && !defined(__llvm__) && !defined(__INTEL_COMPILER) && __GNUC__ < 10 && \
62 __GNUC__ > 4)
63# define HELICS_NODISCARD
64#else
65# define HELICS_NODISCARD [[nodiscard]]
66#endif
67
68#endif