mirror of
https://github.com/sendyne/cppreg.git
synced 2025-05-09 23:24:05 +00:00
* Revise and simplify most enable_if statements in the project. * Update code style in all files. * Update copyright year. * Add a dedicated Memory.h header with the memory device implementation. * Update documentation. * CMake cleanup.
54 lines
1.3 KiB
C++
54 lines
1.3 KiB
C++
//! Internals implementation.
|
|
/**
|
|
* @file Internals.h
|
|
* @author Nicolas Clauvelin (nclauvelin@sendyne.com)
|
|
* @copyright Copyright 2010-2019 Sendyne Corp. All rights reserved.
|
|
*
|
|
* This header collects various implementations which are required for cppreg
|
|
* implementation but not intended to be fully exposed to the user.
|
|
*/
|
|
|
|
|
|
#ifndef CPPREG_INTERNALS_H
|
|
#define CPPREG_INTERNALS_H
|
|
|
|
|
|
#include "Traits.h"
|
|
|
|
|
|
namespace cppreg {
|
|
namespace internals {
|
|
|
|
|
|
//! Overflow check implementation.
|
|
/**
|
|
* @tparam T Data type.
|
|
* @tparam value Value to check.
|
|
* @tparam limit Overflow limit value.
|
|
*
|
|
* This structure defines a type result set to std::true_type if there is
|
|
* no overflow and set to std::false_type if there is overflow.
|
|
* There is overflow if value if strictly larger than limit.
|
|
*/
|
|
template <typename T, T value, T limit>
|
|
struct check_overflow : std::integral_constant<bool, value <= limit> {};
|
|
|
|
|
|
//! is_aligned implementation.
|
|
/**
|
|
* @tparam address Address to be checked for alignment.
|
|
* @tparam alignment Alignment boundary in bytes.
|
|
*
|
|
* This will only derived from std::true_type if the address is aligned.
|
|
*/
|
|
template <Address address, std::size_t alignment>
|
|
struct is_aligned
|
|
: std::integral_constant<bool, (address & (alignment - 1)) == 0> {};
|
|
|
|
|
|
} // namespace internals
|
|
} // namespace cppreg
|
|
|
|
|
|
#endif // CPPREG_INTERNALS_H
|