mirror of
https://github.com/boostorg/core.git
synced 2025-11-30 06:09:56 +01:00
Merge branch 'develop' into feature/max-align
This commit is contained in:
57
include/boost/core/alignof.hpp
Normal file
57
include/boost/core/alignof.hpp
Normal file
@@ -0,0 +1,57 @@
|
||||
#ifndef BOOST_CORE_MAX_ALIGN_HPP_INCLUDED
|
||||
#define BOOST_CORE_MAX_ALIGN_HPP_INCLUDED
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
// Copyright 2023 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <cstddef>
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALIGNOF)
|
||||
|
||||
#define BOOST_CORE_ALIGNOF alignof
|
||||
|
||||
#elif defined(__GNUC__)
|
||||
|
||||
#define BOOST_CORE_ALIGNOF __alignof__
|
||||
|
||||
#elif defined(_MSC_VER)
|
||||
|
||||
#define BOOST_CORE_ALIGNOF __alignof
|
||||
|
||||
#else
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace core
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template<class T> struct alignof_helper
|
||||
{
|
||||
char x;
|
||||
T t;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace core
|
||||
} // namespace boost
|
||||
|
||||
#if defined(__GNUC__)
|
||||
// ignoring -Wvariadic-macros with #pragma doesn't work under GCC
|
||||
# pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#define BOOST_CORE_ALIGNOF(...) offsetof( ::boost::core::detail::alignof_helper<__VA_ARGS__>, t );
|
||||
|
||||
#endif
|
||||
|
||||
#endif // #ifndef BOOST_CORE_MAX_ALIGN_HPP_INCLUDED
|
||||
Reference in New Issue
Block a user