-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
#ifndef ZLL_META_ISOBJECT_HPP | ||
#define ZLL_META_ISOBJECT_HPP | ||
|
||
#include "zll/meta/integral_constant.hpp" | ||
#include "zll/meta/is_array.hpp" | ||
#include "zll/meta/is_class.hpp" | ||
#include "zll/meta/is_scalar.hpp" | ||
#include "zll/meta/is_union.hpp" | ||
|
||
namespace zll { | ||
namespace meta { | ||
|
||
template <typename T> | ||
struct is_object | ||
: bool_constant<is_scalar<T>::value || is_array<T>::value || is_union<T>::value || is_class<T>::value> {}; | ||
|
||
} // namespace meta | ||
} // namespace zll | ||
|
||
#endif // ZLL_META_ISOBJECT_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
#include "zll/meta/is_object.hpp" | ||
|
||
#include <utest.h> | ||
|
||
struct test_struct { | ||
int val; | ||
}; | ||
|
||
enum test_enum {}; | ||
|
||
UTEST(meta_is_object, is_object) { | ||
ASSERT_TRUE(zll::meta::is_object<int>::value); | ||
ASSERT_TRUE(zll::meta::is_object<int*>::value); | ||
ASSERT_TRUE(zll::meta::is_object<test_struct>::value); | ||
ASSERT_TRUE(zll::meta::is_object<test_struct*>::value); | ||
ASSERT_TRUE(zll::meta::is_object<int (*)()>::value); | ||
} | ||
|
||
UTEST(meta_is_object, is_not_object) { | ||
ASSERT_FALSE(zll::meta::is_object<void>::value); | ||
ASSERT_FALSE(zll::meta::is_object<int&>::value); | ||
ASSERT_FALSE(zll::meta::is_object<char*&>::value); | ||
ASSERT_FALSE(zll::meta::is_object<test_struct&>::value); | ||
ASSERT_FALSE(zll::meta::is_object<int()>::value); | ||
ASSERT_FALSE(zll::meta::is_object<void(&)()>::value); | ||
} |