-
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
5 changed files
with
48 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,16 @@ | ||
#ifndef ZLL_META_ISUNION_HPP | ||
#define ZLL_META_ISUNION_HPP | ||
|
||
#include "zll/utils/intrinsics_macros.hpp" | ||
#include "zll/meta/integral_constant.hpp" | ||
|
||
namespace zll { | ||
namespace meta { | ||
|
||
template <typename T> | ||
struct is_union : bool_constant<ZLL_INTRINSICS_IS_UNION(T)> {}; | ||
|
||
} // namespace meta | ||
} // namespace zll | ||
|
||
#endif // ZLL_META_ISUNION_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#ifndef ZLL_UTILS_INTRINSICMACROS_HPP | ||
#define ZLL_UTILS_INTRINSICMACROS_HPP | ||
|
||
#define ZLL_INTRINSICS_IS_UNION(t) __is_union(t) | ||
|
||
#endif // ZLL_UTILS_INTRINSICMACROS_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* 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_union.hpp" | ||
|
||
#include <utest.h> | ||
|
||
typedef union { | ||
char a; | ||
int b; | ||
} test_union; | ||
|
||
struct test_struct { | ||
test_union u; | ||
}; | ||
|
||
UTEST(meta_is_union, sfinae) { | ||
ASSERT_TRUE(zll::meta::is_union<test_union>::value); | ||
ASSERT_FALSE(zll::meta::is_union<test_struct>::value); | ||
ASSERT_FALSE(zll::meta::is_union<int>::value); | ||
} |