Skip to content

Commit

Permalink
Modifying DecorateImmediate to enhance diagnostics
Browse files Browse the repository at this point in the history
This routine cannot be called with zero arguments, anyway, and rather than a cryptic "zero sized array" error message, instead users will see that they are calling the function with the wrong number of arguments.
  • Loading branch information
codemercenary committed Aug 1, 2014
1 parent b38609f commit f78ca80
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions autowiring/AutoPacket.h
Expand Up @@ -345,24 +345,25 @@ class AutoPacket:
/// If multiple values are specified, all will be simultaneously made valid and
/// then invalidated.
/// </remarks>
template<class... Ts>
void DecorateImmediate(const Ts&... immeds) {
template<class T, class... Ts>
void DecorateImmediate(const T& immed, const Ts&... immeds) {
// These are the things we're going to be working with while we perform immediate decoration:
static const std::type_info* sc_typeInfo [] = {&typeid(Ts)...};
const void* pvImmeds[] = {&immeds...};
DecorationDisposition* pTypeSubs[sizeof...(Ts)];
static const std::type_info* sc_typeInfo [] = {&typeid(T), &typeid(Ts)...};
const void* pvImmeds [] = {&immed, &immeds...};
DecorationDisposition* pTypeSubs[1 + sizeof...(Ts)];

// None of the inputs may be shared pointers--if any of the inputs are shared pointers, they must be attached
// to this packet via Decorate, or else dereferenced and used that way.
static_assert(
!is_shared_ptr<T>::value &&
!is_any<is_shared_ptr<Ts>...>::value,
"DecorateImmediate must not be used to attach a shared pointer, use Decorate on such a decoration instead"
);

// Perform standard decoration with a short initialization:
{
std::lock_guard<std::mutex> lk(m_lock);
for(size_t i = 0; i < sizeof...(Ts); i++) {
for(size_t i = 0; i <= sizeof...(Ts); i++) {
pTypeSubs[i] = &m_decorations[*sc_typeInfo[i]];
if(pTypeSubs[i]->wasCheckedOut) {
std::stringstream ss;
Expand All @@ -388,11 +389,11 @@ class AutoPacket:
}

// Now trigger a rescan to hit any deferred, unsatisfiable entries:
static const std::type_info* lamda_typeInfos [] = {&typeid(Ts)...};
static const std::type_info* lamda_typeInfos [] = {&typeid(T), &typeid(Ts)...};
for(auto ti : lamda_typeInfos)
MarkUnsatisfiable(*ti);
}),
PulseSatisfaction(pTypeSubs, sizeof...(Ts));
PulseSatisfaction(pTypeSubs, 1 + sizeof...(Ts));
}

/// <returns>
Expand Down

0 comments on commit f78ca80

Please sign in to comment.