-
Notifications
You must be signed in to change notification settings - Fork 157
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
3 changed files
with
112 additions
and
11 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 @@ | ||
// Copyright (c) 2023 Antony Polukhin | ||
// | ||
// Distributed under the Boost Software License, Version 1.0. (See accompanying | ||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
|
||
#include <boost/pfr/tuple_size.hpp> | ||
|
||
struct A | ||
{ | ||
template <typename... Args> | ||
explicit A(Args&&...) {} | ||
}; | ||
|
||
int main() { | ||
(void)boost::pfr::tuple_size<A>::value; // Must be a compile time error | ||
} |
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 @@ | ||
// Copyright (c) 2023 Antony Polukhin | ||
// | ||
// Distributed under the Boost Software License, Version 1.0. (See accompanying | ||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
|
||
#include <boost/pfr/tuple_size.hpp> | ||
|
||
struct A | ||
{ | ||
template <typename Arg0, typename... Args> | ||
explicit A(Arg0&&, Args&&...) {} | ||
}; | ||
|
||
int main() { | ||
(void)boost::pfr::tuple_size<A>::value; // Must be a compile time error | ||
} |
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 |
---|---|---|
@@ -1,21 +1,90 @@ | ||
// Copyright (c) 2016-2022 Antony Polukhin | ||
// Copyright (c) 2016-2023 Antony Polukhin | ||
// | ||
// Distributed under the Boost Software License, Version 1.0. (See accompanying | ||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
|
||
#include <boost/pfr/tuple_size.hpp> | ||
|
||
struct bf { | ||
unsigned int i1: 1; | ||
unsigned int i2: 1; | ||
unsigned int i3: 1; | ||
unsigned int i4: 1; | ||
unsigned int i5: 1; | ||
unsigned int i6: 1; | ||
#include <cstdint> | ||
|
||
struct bf7 | ||
{ | ||
uint8_t b0 : 1; | ||
uint8_t b1 : 1; | ||
uint8_t b2 : 1; | ||
uint8_t b3 : 1; | ||
uint8_t b4 : 1; | ||
uint8_t b5 : 1; | ||
uint8_t b6 : 1; | ||
}; | ||
static_assert(sizeof(bf7) == 1, ""); | ||
|
||
int main() { | ||
static_assert(boost::pfr::tuple_size<bf>::value == 6, ""); | ||
} | ||
struct bf8 | ||
{ | ||
uint8_t b0 : 1; | ||
uint8_t b1 : 1; | ||
uint8_t b2 : 1; | ||
uint8_t b3 : 1; | ||
uint8_t b4 : 1; | ||
uint8_t b5 : 1; | ||
uint8_t b6 : 1; | ||
uint8_t b7 : 1; | ||
}; | ||
static_assert(sizeof(bf8) == 1, ""); | ||
|
||
struct bf16 | ||
{ | ||
uint8_t b0 : 1; | ||
uint8_t b1 : 1; | ||
uint8_t b2 : 1; | ||
uint8_t b3 : 1; | ||
uint8_t b4 : 1; | ||
uint8_t b5 : 1; | ||
uint8_t b6 : 1; | ||
uint8_t b7 : 1; | ||
uint8_t b8 : 1; | ||
uint8_t b9 : 1; | ||
uint8_t b10 : 1; | ||
uint8_t b11 : 1; | ||
uint8_t b12 : 1; | ||
uint8_t b13 : 1; | ||
uint8_t b14 : 1; | ||
uint8_t b15 : 1; | ||
}; | ||
static_assert(sizeof(bf16) == 2, ""); | ||
|
||
struct bf24 | ||
{ | ||
uint8_t b0 : 1; | ||
uint8_t b1 : 1; | ||
uint8_t b2 : 1; | ||
uint8_t b3 : 1; | ||
uint8_t b4 : 1; | ||
uint8_t b5 : 1; | ||
uint8_t b6 : 1; | ||
uint8_t b7 : 1; | ||
uint8_t b8 : 1; | ||
uint8_t b9 : 1; | ||
uint8_t b10 : 1; | ||
uint8_t b11 : 1; | ||
uint8_t b12 : 1; | ||
uint8_t b13 : 1; | ||
uint8_t b14 : 1; | ||
uint8_t b15 : 1; | ||
uint8_t b16 : 1; | ||
uint8_t b17 : 1; | ||
uint8_t b18 : 1; | ||
uint8_t b19 : 1; | ||
uint8_t b20 : 1; | ||
uint8_t b21 : 1; | ||
uint8_t b22 : 1; | ||
uint8_t b23 : 1; | ||
}; | ||
static_assert(sizeof(bf24) == 3, ""); | ||
|
||
int main() { | ||
static_assert(boost::pfr::tuple_size_v<bf7> == 7, ""); | ||
static_assert(boost::pfr::tuple_size_v<bf8> == 8, ""); | ||
static_assert(boost::pfr::tuple_size_v<bf8> == 16, ""); | ||
static_assert(boost::pfr::tuple_size_v<bf24> == 24, ""); | ||
} |