dune-common  2.11
no_unique_address.hh
Go to the documentation of this file.
1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 sts=2:
3 // SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
4 // SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
5 #ifndef DUNE_COMMON_STD_NO_UNIQUE_ADDRESS_HH
6 #define DUNE_COMMON_STD_NO_UNIQUE_ADDRESS_HH
7 
8 #if __has_include(<version>)
9 #include <version>
10 #endif
11 
12 // Provide the macro DUNE_NO_UNIQUE_ADDRESS that expands to [[no_unique_address]]
13 // or similar depending on the compiler (version)
14 
15 #if _MSC_VER
16  #if _MSC_VER >= 1929 // VS2019 v16.10 and later
17  #define DUNE_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]]
18  #else // no-op in MSVC v14x ABI
19  #define DUNE_NO_UNIQUE_ADDRESS /* [[no_unique_address]] */
20  #endif
21 #elif __has_cpp_attribute(no_unique_address) >= 201803L
22  #define DUNE_NO_UNIQUE_ADDRESS [[no_unique_address]]
23 #else
24  #define DUNE_NO_UNIQUE_ADDRESS /* [[no_unique_address]] */
25 #endif
26 
27 #endif // DUNE_COMMON_STD_NO_UNIQUE_ADDRESS_HH