mirror of
https://github.com/fmtlib/fmt.git
synced 2025-07-31 11:17:35 +02:00
Encode types using 5 bits
This is needed to support more than the current 16 types.
This commit is contained in:
committed by
Victor Zverovich
parent
b55551f900
commit
dd11d45847
@@ -889,7 +889,7 @@ using mapped_type_constant =
|
|||||||
typename Context::char_type>;
|
typename Context::char_type>;
|
||||||
|
|
||||||
// Maximum number of arguments with packed types.
|
// Maximum number of arguments with packed types.
|
||||||
enum { max_packed_args = 15 };
|
enum { max_packed_args = 12 };
|
||||||
enum : unsigned long long { is_unpacked_bit = 1ull << 63 };
|
enum : unsigned long long { is_unpacked_bit = 1ull << 63 };
|
||||||
|
|
||||||
template <typename Context> class arg_map;
|
template <typename Context> class arg_map;
|
||||||
@@ -1052,7 +1052,7 @@ template <typename> constexpr unsigned long long encode_types() { return 0; }
|
|||||||
template <typename Context, typename Arg, typename... Args>
|
template <typename Context, typename Arg, typename... Args>
|
||||||
constexpr unsigned long long encode_types() {
|
constexpr unsigned long long encode_types() {
|
||||||
return mapped_type_constant<Arg, Context>::value |
|
return mapped_type_constant<Arg, Context>::value |
|
||||||
(encode_types<Context, Args...>() << 4);
|
(encode_types<Context, Args...>() << 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Context, typename T>
|
template <typename Context, typename T>
|
||||||
@@ -1197,8 +1197,8 @@ template <typename Context> class basic_format_args {
|
|||||||
bool is_packed() const { return (types_ & internal::is_unpacked_bit) == 0; }
|
bool is_packed() const { return (types_ & internal::is_unpacked_bit) == 0; }
|
||||||
|
|
||||||
internal::type type(int index) const {
|
internal::type type(int index) const {
|
||||||
int shift = index * 4;
|
int shift = index * 5;
|
||||||
return static_cast<internal::type>((types_ & (0xfull << shift)) >> shift);
|
return static_cast<internal::type>((types_ >> shift) & 0x1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
friend class internal::arg_map<Context>;
|
friend class internal::arg_map<Context>;
|
||||||
|
Reference in New Issue
Block a user