Skip to content

Commit

Permalink
Merge pull request #84 from leapmotion/clarify-static-assert
Browse files Browse the repository at this point in the history
Clarify some static asserts
  • Loading branch information
gtremper committed Aug 26, 2014
2 parents 26e2a3a + 67a668b commit 33751f9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion autowiring/CoreContext.h
Expand Up @@ -542,7 +542,7 @@ class CoreContext:
static_assert(std::is_base_of<Object, TActual>::value, "Constructive type does not implement Object as expected");
static_assert(
std::is_base_of<Object, T>::value || !has_static_new<T>::value,
"If type T provides a static new method, then the constructed type MUST directly inherit Object"
"If type T provides a static New method, then the constructed type MUST directly inherit Object"
);

// First see if the object has already been injected:
Expand Down
4 changes: 2 additions & 2 deletions autowiring/CreationRules.h
Expand Up @@ -24,15 +24,15 @@ struct CreationRules {
auto retVal = U::New(std::forward<Args>(args)...);
static_assert(
std::is_convertible<decltype(retVal), U*>::value,
"Attempted to create T using T::New, but the return value of T::New is not derived from T"
"Attempted to create T using T::New, but the type of T::New() is not derived from T"
);
return retVal;
}

template<typename U, typename... Args>
static typename std::enable_if<!has_static_new<U, Args...>::value, U*>::type New(Args&&... args) {
static_assert(!std::is_abstract<U>::value, "Cannot create a type which is abstract");
static_assert(!has_static_new<U, Args...>::value, "Can't inject member with arguments if it has a static new");
static_assert(!has_static_new<U, Args...>::value, "Can't inject member with arguments if it has a static New");

// Allocate slot first before registration
auto* pSpace = Allocate<U>(nullptr);
Expand Down
2 changes: 1 addition & 1 deletion src/autowiring/test/FactoryTest.cpp
Expand Up @@ -37,7 +37,7 @@ class ClassWithStaticNew:

static_assert(has_simple_constructor<ClassWithStaticNew>::value, "Class with default-argument constructor was not correctly detected as such ");
static_assert(has_static_new<ClassWithStaticNew>::value, "Class with static allocator was not correctly detected as having one");
static_assert(!has_static_new<Object>::value, "Static new detected on a class that does not have a static new");
static_assert(!has_static_new<Object>::value, "Static New detected on a class that does not have a static New");

TEST_F(FactoryTest, VerifyFactoryCall) {
// Try to create the static new type:
Expand Down

0 comments on commit 33751f9

Please sign in to comment.