mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 08:44:19 -04:00
putil: make BitMask et al literal types
This commit is contained in:
parent
db5dd98d33
commit
aa1b06f132
@ -18,17 +18,7 @@ TypeHandle BitMask<WType, nbits>::_type_handle;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
template<class WType, int nbits>
|
template<class WType, int nbits>
|
||||||
INLINE BitMask<WType, nbits>::
|
constexpr BitMask<WType, nbits>::
|
||||||
BitMask() :
|
|
||||||
_word(0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
template<class WType, int nbits>
|
|
||||||
INLINE BitMask<WType, nbits>::
|
|
||||||
BitMask(WordType init_value) :
|
BitMask(WordType init_value) :
|
||||||
_word(init_value)
|
_word(init_value)
|
||||||
{
|
{
|
||||||
@ -170,7 +160,7 @@ is_zero() const {
|
|||||||
template<class WType, int nbits>
|
template<class WType, int nbits>
|
||||||
INLINE bool BitMask<WType, nbits>::
|
INLINE bool BitMask<WType, nbits>::
|
||||||
is_all_on() const {
|
is_all_on() const {
|
||||||
return (~_word == 0);
|
return _word == (WordType)~0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -12,7 +12,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "bitMask.h"
|
#include "bitMask.h"
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
template class BitMask<uint16_t, 16>;
|
template class BitMask<uint16_t, 16>;
|
||||||
template class BitMask<uint32_t, 32>;
|
template class BitMask<uint32_t, 32>;
|
||||||
template class BitMask<uint64_t, 64>;
|
template class BitMask<uint64_t, 64>;
|
||||||
|
|
||||||
|
#ifndef CPPPARSER
|
||||||
|
static_assert(std::is_literal_type<BitMask16>::value, "BitMask16 is not a literal type");
|
||||||
|
static_assert(std::is_literal_type<BitMask32>::value, "BitMask32 is not a literal type");
|
||||||
|
static_assert(std::is_literal_type<BitMask64>::value, "BitMask64 is not a literal type");
|
||||||
|
#endif
|
||||||
|
@ -36,8 +36,8 @@ public:
|
|||||||
PUBLISHED:
|
PUBLISHED:
|
||||||
enum { num_bits = nbits };
|
enum { num_bits = nbits };
|
||||||
|
|
||||||
INLINE BitMask();
|
constexpr BitMask() = default;
|
||||||
INLINE BitMask(WordType init_value);
|
constexpr BitMask(WordType init_value);
|
||||||
|
|
||||||
INLINE static BitMask<WType, nbits> all_on();
|
INLINE static BitMask<WType, nbits> all_on();
|
||||||
INLINE static BitMask<WType, nbits> all_off();
|
INLINE static BitMask<WType, nbits> all_off();
|
||||||
@ -131,7 +131,7 @@ public:
|
|||||||
INLINE void generate_hash(ChecksumHashGenerator &hashgen) const;
|
INLINE void generate_hash(ChecksumHashGenerator &hashgen) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
WordType _word;
|
WordType _word = 0u;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static TypeHandle get_class_type() {
|
static TypeHandle get_class_type() {
|
||||||
|
@ -14,36 +14,6 @@
|
|||||||
template<class BMType>
|
template<class BMType>
|
||||||
TypeHandle DoubleBitMask<BMType>::_type_handle;
|
TypeHandle DoubleBitMask<BMType>::_type_handle;
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
template<class BMType>
|
|
||||||
INLINE DoubleBitMask<BMType>::
|
|
||||||
DoubleBitMask() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
template<class BMType>
|
|
||||||
INLINE DoubleBitMask<BMType>::
|
|
||||||
DoubleBitMask(const DoubleBitMask<BMType> ©) :
|
|
||||||
_lo(copy._lo),
|
|
||||||
_hi(copy._hi)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
template<class BMType>
|
|
||||||
INLINE DoubleBitMask<BMType> &DoubleBitMask<BMType>::
|
|
||||||
operator = (const DoubleBitMask<BMType> ©) {
|
|
||||||
_lo = copy._lo;
|
|
||||||
_hi = copy._hi;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a DoubleBitMask whose bits are all on.
|
* Returns a DoubleBitMask whose bits are all on.
|
||||||
*/
|
*/
|
||||||
@ -111,14 +81,6 @@ range(int low_bit, int size) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
template<class BMType>
|
|
||||||
INLINE DoubleBitMask<BMType>::
|
|
||||||
~DoubleBitMask() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of bits available to set in the doubleBitMask.
|
* Returns the number of bits available to set in the doubleBitMask.
|
||||||
*/
|
*/
|
||||||
|
@ -12,6 +12,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "doubleBitMask.h"
|
#include "doubleBitMask.h"
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
template class DoubleBitMask<BitMaskNative>;
|
template class DoubleBitMask<BitMaskNative>;
|
||||||
template class DoubleBitMask<DoubleBitMaskNative>;
|
template class DoubleBitMask<DoubleBitMaskNative>;
|
||||||
|
|
||||||
|
#ifndef CPPPARSER
|
||||||
|
static_assert(std::is_literal_type<DoubleBitMaskNative>::value, "DoubleBitMaskNative is not a literal type");
|
||||||
|
static_assert(std::is_literal_type<QuadBitMaskNative>::value, "QuadBitMaskNative is not a literal type");
|
||||||
|
#endif
|
||||||
|
@ -37,9 +37,7 @@ PUBLISHED:
|
|||||||
num_bits = BMType::num_bits * 2,
|
num_bits = BMType::num_bits * 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
INLINE DoubleBitMask();
|
constexpr DoubleBitMask() = default;
|
||||||
INLINE DoubleBitMask(const DoubleBitMask<BMType> ©);
|
|
||||||
INLINE DoubleBitMask<BMType> &operator = (const DoubleBitMask<BMType> ©);
|
|
||||||
|
|
||||||
INLINE static DoubleBitMask<BMType> all_on();
|
INLINE static DoubleBitMask<BMType> all_on();
|
||||||
INLINE static DoubleBitMask<BMType> all_off();
|
INLINE static DoubleBitMask<BMType> all_off();
|
||||||
@ -47,8 +45,6 @@ PUBLISHED:
|
|||||||
INLINE static DoubleBitMask<BMType> bit(int index);
|
INLINE static DoubleBitMask<BMType> bit(int index);
|
||||||
INLINE static DoubleBitMask<BMType> range(int low_bit, int size);
|
INLINE static DoubleBitMask<BMType> range(int low_bit, int size);
|
||||||
|
|
||||||
INLINE ~DoubleBitMask();
|
|
||||||
|
|
||||||
constexpr static bool has_max_num_bits() {return true;}
|
constexpr static bool has_max_num_bits() {return true;}
|
||||||
constexpr static int get_max_num_bits() {return num_bits;}
|
constexpr static int get_max_num_bits() {return num_bits;}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user