forked from boostorg/config
Merge pull request #273 from boostorg/no_unique_address
Add BOOST_ATTRIBUTE_NO_UNIQUE_ADDRESS.
This commit is contained in:
@ -1277,6 +1277,8 @@ Usage example:
|
||||
can be used to disable compiler warnings relating to unused types or variables.]]
|
||||
[[`BOOST_ATTRIBUTE_NODISCARD`][Expands to `[[nodiscard]]` when this is available -
|
||||
can be used to create a warning when a type or variable is unused.]]
|
||||
[[`BOOST_ATTRIBUTE_NO_UNIQUE_ADDRESS`][Expands to `[[no_unique_address]]` when this is available -
|
||||
can be used to indicate that a non-static data member need not have a unique address (for example empty classes).]]
|
||||
[[`BOOST_MAY_ALIAS`, `BOOST_NO_MAY_ALIAS`][
|
||||
`BOOST_MAY_ALIAS` expands to a type attribute that can be used to mark types that may
|
||||
alias other types. Pointers or references to such marked types can be used to access objects
|
||||
|
@ -999,10 +999,16 @@ namespace std{ using ::type_info; }
|
||||
#if __has_cpp_attribute(nodiscard)
|
||||
# define BOOST_ATTRIBUTE_NODISCARD [[nodiscard]]
|
||||
#endif
|
||||
#if __has_cpp_attribute(no_unique_address)
|
||||
# define BOOST_ATTRIBUTE_NO_UNIQUE_ADDRESS [[no_unique_address]]
|
||||
#endif
|
||||
#endif
|
||||
#ifndef BOOST_ATTRIBUTE_NODISCARD
|
||||
# define BOOST_ATTRIBUTE_NODISCARD
|
||||
#endif
|
||||
#ifndef BOOST_ATTRIBUTE_NO_UNIQUE_ADDRESS
|
||||
# define BOOST_ATTRIBUTE_NO_UNIQUE_ADDRESS
|
||||
#endif
|
||||
|
||||
#define BOOST_STATIC_CONSTEXPR static BOOST_CONSTEXPR_OR_CONST
|
||||
|
||||
|
@ -42,6 +42,13 @@ struct BOOST_ATTRIBUTE_NODISCARD nodiscard_struct {};
|
||||
|
||||
#define test_fallthrough(x) foobar(x)
|
||||
|
||||
struct empty {};
|
||||
struct no_unique
|
||||
{
|
||||
int a;
|
||||
BOOST_ATTRIBUTE_NO_UNIQUE_ADDRESS empty b;
|
||||
};
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
@ -56,6 +63,7 @@ int main()
|
||||
if(BOOST_UNLIKELY(!result))
|
||||
always_throw();
|
||||
nodiscard_struct s;
|
||||
no_unique no_un;
|
||||
}
|
||||
catch(int)
|
||||
{
|
||||
|
Reference in New Issue
Block a user