1/*
2 * Copyright Andrey Semashev 2007 - 2015.
3 * Distributed under the Boost Software License, Version 1.0.
4 * (See accompanying file LICENSE_1_0.txt or copy at
5 * http://www.boost.org/LICENSE_1_0.txt)
6 */
7/*!
8 * \file alignment_gap_between.hpp
9 * \author Andrey Semashev
10 * \date 20.11.2007
11 *
12 * \brief This header is the Boost.Log library implementation, see the library documentation
13 * at http://www.boost.org/doc/libs/release/libs/log/doc/html/index.html.
14 */
15
16#ifndef BOOST_LOG_ALIGNMENT_GAP_BETWEEN_HPP_INCLUDED_
17#define BOOST_LOG_ALIGNMENT_GAP_BETWEEN_HPP_INCLUDED_
18
19#include <boost/log/detail/config.hpp>
20#include <boost/type_traits/alignment_of.hpp>
21#include <boost/log/detail/header.hpp>
22
23namespace boost {
24
25BOOST_LOG_OPEN_NAMESPACE
26
27namespace aux {
28
29//! The metafunction computes the minimal gap between objects t1 and t2 of types T1 and T2
30//! that would be needed to maintain the alignment of t2 if it's placed right after t1
31template< typename T1, typename T2 >
32struct alignment_gap_between
33{
34 enum _
35 {
36 T2_alignment = boost::alignment_of< T2 >::value,
37 tail_size = sizeof(T1) % T2_alignment,
38 value = tail_size > 0 ? T2_alignment - tail_size : 0
39 };
40};
41
42} // namespace aux
43
44BOOST_LOG_CLOSE_NAMESPACE // namespace log
45
46} // namespace boost
47
48#include <boost/log/detail/footer.hpp>
49
50#endif // BOOST_LOG_ALIGNMENT_GAP_BETWEEN_HPP_INCLUDED_
51

source code of boost/libs/log/src/alignment_gap_between.hpp