Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend ArgLists to support serialization/deserialization in third-party components #389

Merged
merged 1 commit into from
Sep 27, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -1377,10 +1377,7 @@ class ArgList {
};

internal::Arg::Type type(unsigned index) const {
unsigned shift = index * 4;
uint64_t mask = 0xf;
return static_cast<internal::Arg::Type>(
(types_ & (mask << shift)) >> shift);
return type(types_, index);
}

template <typename Char>
Expand All @@ -1397,6 +1394,8 @@ class ArgList {
ArgList(ULongLong types, const internal::Arg *args)
: types_(types), args_(args) {}

uint64_t types() const { return types_; }

/** Returns the argument at specified index. */
internal::Arg operator[](unsigned index) const {
using internal::Arg;
Expand All @@ -1422,6 +1421,13 @@ class ArgList {
}
return args_[index];
}

static internal::Arg::Type type(uint64_t types, unsigned index) {
unsigned shift = index * 4;
uint64_t mask = 0xf;
return static_cast<internal::Arg::Type>(
(types & (mask << shift)) >> shift);
}
};

#define FMT_DISPATCH(call) static_cast<Impl*>(this)->call
Expand Down