Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
Namespaces | Functions
integer.hpp File Reference
#include "shambase/aliases_int.hpp"
#include "shambase/type_traits.hpp"
#include <type_traits>
+ Include dependency graph for integer.hpp:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  shambase
 namespace for basic c++ utilities
 

Functions

template<class T , std::enable_if_t< std::is_integral_v< T >, int > = 0>
constexpr bool shambase::is_pow_of_two_fast (T v) noexcept
 determine if v is a power of two Warning : this function return true if v == 0 Source : https://graphics.stanford.edu/~seander/bithacks.html
 
template<class T , std::enable_if_t< std::is_integral_v< T >, int > = 0>
constexpr bool shambase::is_pow_of_two (T v) noexcept
 determine if v is a power of two and check if v==0 Source : https://graphics.stanford.edu/~seander/bithacks.html
 
template<class T , std::enable_if_t< std::is_integral_v< T >||std::is_signed_v< T >, int > = 0>
constexpr bool shambase::sign_differ (T a, T b) noexcept
 check if the sign of the two integers differs Source : https://graphics.stanford.edu/~seander/bithacks.html
 
template<class T , std::enable_if_t< std::is_integral_v< T >, int > = 0>
void shambase::xor_swap (T &a, T &b)
 swap two values using xor Source : https://graphics.stanford.edu/~seander/bithacks.html
 
template<class T , std::enable_if_t< std::is_integral_v< T >||(!std::is_signed_v< T >), int > = 0>
constexprshambase::roundup_pow2 (T v) noexcept
 round up to the next power of two Source : https://graphics.stanford.edu/~seander/bithacks.html
 
constexpr u32 shambase::group_count (u32 len, u32 group_size)
 Calculates the number of groups based on the length and group size.
 
template<class T , std::enable_if_t< std::is_integral_v< T >, int > = 0>
shambase::select_bit (T value, T bitnum)
 Selects and returns the bit at a specific position in the given value.
 
template<class T , std::enable_if_t< std::is_integral_v< T >, int > = 0>
constexprshambase::most_sig_bit_mask () noexcept
 Generates a mask with only the most significant bit set.
 
template<class T , std::enable_if_t< std::is_integral_v< T >, int > = 0>
constexpr bool shambase::is_most_sig_bit_set (const T x) noexcept
 Checks if the most significant bit is set in the given value.
 
template<i32 power, class T >
constexprshambase::pow_constexpr (T a) noexcept
 Calculates the power of a number at compile time.
 
template<u32 flag>
constexpr bool shambase::is_flag_on (u32 val)
 

Detailed Description

Author
Timothée David–Cléris (tim.s.nosp@m.hamr.nosp@m.ock@p.nosp@m.roto.nosp@m.n.me)

Definition in file integer.hpp.