1/*
2 * Copyright Andrey Semashev 2016.
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 bit_tools.hpp
9 * \author Andrey Semashev
10 * \date 16.01.2016
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_BIT_TOOLS_HPP_INCLUDED_
17#define BOOST_LOG_BIT_TOOLS_HPP_INCLUDED_
18
19#include <boost/log/detail/config.hpp>
20#include <cstddef>
21#include <boost/cstdint.hpp>
22#include <boost/log/detail/header.hpp>
23
24namespace boost {
25
26BOOST_LOG_OPEN_NAMESPACE
27
28namespace aux {
29
30//! Checks that the integer is a power of 2.
31template< typename T >
32inline BOOST_CONSTEXPR bool is_power_of_2(T n) BOOST_NOEXCEPT
33{
34 return n != (T)0 && (n & (n - (T)1)) == (T)0;
35}
36
37//! Returns an integer comprising the four characters
38inline BOOST_CONSTEXPR uint32_t make_fourcc(unsigned char c1, unsigned char c2, unsigned char c3, unsigned char c4) BOOST_NOEXCEPT
39{
40 return (static_cast< uint32_t >(c1) << 24) | (static_cast< uint32_t >(c2) << 16) | (static_cast< uint32_t >(c3) << 8) | static_cast< uint32_t >(c4);
41}
42
43} // namespace aux
44
45BOOST_LOG_CLOSE_NAMESPACE // namespace log
46
47} // namespace boost
48
49#include <boost/log/detail/footer.hpp>
50
51#endif // BOOST_LOG_BIT_TOOLS_HPP_INCLUDED_
52

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