General Utility Library for C++14  2.11
Namespaces | Typedefs | Enumerations | Functions
bit_manip.h File Reference

Detailed Description

Declaration of bit manipulation utility functions for the General Utility Library.

Authors
General Utility Library Contributors
Date
Created on 17 October 2019

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 2.1 of the license, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this program. If not, see https://www.gnu.org/licenses/.

#include <cassert>
#include <type_traits>
#include "gul14/internal.h"
Include dependency graph for bit_manip.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 gul14
 Namespace gul14 contains all functions and classes of the General Utility Library.
 

Typedefs

template<typename T >
using gul14::BitFunctionReturnType = std::enable_if_t< std::is_integral< T >::value and not std::is_same< std::decay_t< T >, bool >::value, std::decay_t< T > >
 Return type of the bit manipulation functions. More...
 

Enumerations

enum class  gul14::endian { gul14::little , gul14::big , gul14::native }
 An enum to determine the endianness of multi-byte scalars on the current platform. More...
 

Functions

template<typename T = unsigned, typename ReturnT = BitFunctionReturnType<T>>
constexpr auto gul14::bit_set (unsigned bit) noexcept -> ReturnT
 Set a bit in an integral type. More...
 
template<typename T , typename ReturnT = BitFunctionReturnType<T>>
constexpr auto gul14::bit_set (T previous, unsigned bit) noexcept -> ReturnT
 Set a bit in an integral value. More...
 
template<typename T , typename ReturnT = BitFunctionReturnType<T>>
constexpr auto gul14::bit_reset (T previous, unsigned bit) noexcept -> ReturnT
 Reset a bit in an integral value. More...
 
template<typename T , typename ReturnT = BitFunctionReturnType<T>>
constexpr auto gul14::bit_flip (T previous, unsigned bit) noexcept -> ReturnT
 Flip a bit in an integral value. More...
 
template<typename T >
constexpr bool gul14::bit_test (T bits, unsigned bit) noexcept
 Test a bit in an integral value. More...
 
constexpr bool gul14::is_big_endian ()
 Determine whether this platform uses big-endian (Motorola) order for storing multi-byte quantities in memory. More...
 
constexpr bool gul14::is_little_endian ()
 Determine whether this platform uses little-endian (Intel) order for storing multi-byte quantities in memory. More...