constexpr union with POD Struct members using parameter pack expansions2019 Community Moderator ElectionHow to fill array with contents of a template parameter pack?How do I implement “perfect forwarding” in a class template?Compiling with gcc fails if using lambda function for QObject::connect()gcc:g++ being bureaucratic with template template friendsAddition of two matrix using structerror: invalid user defined conversion from char to const key_type&Cannot initialize const int from unpacked tupleHow to return a static const int std::array from a method?Function receiving a const struct and cin commendWhy did this error occur? c++ library buildconstexpr struct member initialisation
CLI: Get information Ubuntu releases
Why are there no stars visible in cislunar space?
How to find the largest number(s) in a list of elements, possibly non-unique?
Have the tides ever turned twice on any open problem?
"Marked down as someone wanting to sell shares." What does that mean?
PTIJ: Where did Achashverosh's years wander off to?
Knife as defense against stray dogs
Was World War I a war of liberals against authoritarians?
Pre-Employment Background Check With Consent For Future Checks
Did Nintendo change its mind about 68000 SNES?
How are passwords stolen from companies if they only store hashes?
What is it called when someone votes for an option that's not their first choice?
Error in master's thesis, I do not know what to do
Gauss brackets with double vertical lines
Do people actually use the word "kaputt" in conversation?
How do researchers send unsolicited emails asking for feedback on their works?
Why do I have a large white artefact on the rendered image?
Is there any common country to visit for uk and schengen visa?
How to understand 「僕は誰より彼女が好きなんだ。」
If I cast the Enlarge/Reduce spell on an arrow, what weapon could it count as?
Why is participating in the European Parliamentary elections used as a threat?
How to test the sharpness of a knife?
What kind of footwear is suitable for walking in micro gravity environment?
Does fire aspect on a sword, destroy mob drops?
constexpr union with POD Struct members using parameter pack expansions
2019 Community Moderator ElectionHow to fill array with contents of a template parameter pack?How do I implement “perfect forwarding” in a class template?Compiling with gcc fails if using lambda function for QObject::connect()gcc:g++ being bureaucratic with template template friendsAddition of two matrix using structerror: invalid user defined conversion from char to const key_type&Cannot initialize const int from unpacked tupleHow to return a static const int std::array from a method?Function receiving a const struct and cin commendWhy did this error occur? c++ library buildconstexpr struct member initialisation
I am trying construct a constexpr union which wraps 3 types. The union can contain a raw uint8_t array
or fixed length arrays of PODTypeA
or PODTypeB
. The lengths of these arrays are known at compile time and given by constexpr values.
The POD structures are very simple:
struct PODTypeA
int a;
int b;
;
or
struct PODTypeB
uint32_t a;
uint32_t b;
;
The embedded environment does not have the standard template library available. As such, I cannot use the constexpr std::array<T,N>
which would make things a lot easier.
Shown below is a constexpr Array(const Args&... args)
array implementation, which should function as a constexpr data member to hold array fields.
template <typename T, std::size_t Size>
struct Array
T data[Size];
template <typename ...Args>
constexpr Array(const Args&... args)
: data args...
;
I don't fully understand how the parameter pack expansion works (effectively memcpy(ing) the array via the compiler to the specified union member). If someone could explain that it would be a plus. I found the above Array template parameter pack expander in the checked answer to the following stack overlflow question (where there is also a live example).
I put this in a coliru project but I am having lots of compile issues.
I have 3 constructors for the union, each one of these takes a fixed length array parameter as follows:
constexpr static auto gSizeBytes = 2048;
constexpr static int gArraySizeA = 2;
constexpr static int gArraySizeB = 3;
union UnionStruct
explicit constexpr UnionStruct(
const uint8_t(&rParam)[gSizeBytes] = )
: byteArray(rParam)
explicit constexpr UnionStruct(
const PODTypeA(&rParam)[gArraySizeA])
: arrayA(rParam)
explicit constexpr UnionStruct(
const PODTypeB(&rParam)[gArraySizeB])
: arrayB(rParam)
Array<uint8_t, gSizeBytes> byteArray;
Array<PODTypeA, gArraySizeA> arrayA;
Array<PODTypeB, gArraySizeB> arrayB;
;
And here is how I expect to use it:
int main()
PODTypeA[UnionStruct::gArraySizeA] arrayTypeA = 1,2, 3,4;
// construct union from fixed PODTypeA array with 2 elements
UnionStruct foo (arrayTypeA);
The compiler issues the following errors:
g++ -std=c++17 -O2 -Wall -pedantic -pthread main.cpp && ./a.out
main.cpp: In instantiation of 'constexpr Array<T, Size>::Array(const Args& ...) [with Args = unsigned char [2048]; T = unsigned char; long unsigned int Size = 2048]':
main.cpp:34:27: required from here
main.cpp:12:25: error: invalid conversion from 'const unsigned char*' to 'unsigned char' [-fpermissive]
: data args...
^
main.cpp: In instantiation of 'constexpr Array<T, Size>::Array(const Args& ...) [with Args = PODTypeA [2]; T = PODTypeA; long unsigned int Size = 2]':
main.cpp:39:24: required from here
main.cpp:12:25: error: invalid conversion from 'const PODTypeA*' to 'int' [-fpermissive]
main.cpp: In instantiation of 'constexpr Array<T, Size>::Array(const Args& ...) [with Args = PODTypeB [3]; T = PODTypeB; long unsigned int Size = 3]':
main.cpp:44:24: required from here
main.cpp:12:25: error: invalid conversion from 'const PODTypeB*' to 'uint32_t' aka 'unsigned int' [-fpermissive]
main.cpp: In function 'int main()':
main.cpp:54:14: error: expected identifier before numeric constant
PODTypeA[2] arrayTypeA = 1,2, 3,4;
^
main.cpp:54:14: error: expected ']' before numeric constant
PODTypeA[2] arrayTypeA = 1,2, 3,4;
^
]
main.cpp:54:13: error: structured binding declaration cannot have type 'PODTypeA'
PODTypeA[2] arrayTypeA = 1,2, 3,4;
^
main.cpp:54:13: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
main.cpp:54:13: error: empty structured binding declaration
main.cpp:54:17: error: expected initializer before 'arrayTypeA'
PODTypeA[2] arrayTypeA = 1,2, 3,4;
^~~~~~~~~~
main.cpp:56:22: error: 'arrayTypeA' was not declared in this scope
UnionStruct foo (arrayTypeA);
^~~~~~~~~~
main.cpp:56:22: note: suggested alternative: 'gArraySizeA'
UnionStruct foo (arrayTypeA);
^~~~~~~~~~
gArraySizeA
main.cpp:54:13: warning: unused structured binding declaration [-Wunused-variable]
PODTypeA[2] arrayTypeA = 1,2, 3,4;
^
c++11 union c++17 constexpr
add a comment |
I am trying construct a constexpr union which wraps 3 types. The union can contain a raw uint8_t array
or fixed length arrays of PODTypeA
or PODTypeB
. The lengths of these arrays are known at compile time and given by constexpr values.
The POD structures are very simple:
struct PODTypeA
int a;
int b;
;
or
struct PODTypeB
uint32_t a;
uint32_t b;
;
The embedded environment does not have the standard template library available. As such, I cannot use the constexpr std::array<T,N>
which would make things a lot easier.
Shown below is a constexpr Array(const Args&... args)
array implementation, which should function as a constexpr data member to hold array fields.
template <typename T, std::size_t Size>
struct Array
T data[Size];
template <typename ...Args>
constexpr Array(const Args&... args)
: data args...
;
I don't fully understand how the parameter pack expansion works (effectively memcpy(ing) the array via the compiler to the specified union member). If someone could explain that it would be a plus. I found the above Array template parameter pack expander in the checked answer to the following stack overlflow question (where there is also a live example).
I put this in a coliru project but I am having lots of compile issues.
I have 3 constructors for the union, each one of these takes a fixed length array parameter as follows:
constexpr static auto gSizeBytes = 2048;
constexpr static int gArraySizeA = 2;
constexpr static int gArraySizeB = 3;
union UnionStruct
explicit constexpr UnionStruct(
const uint8_t(&rParam)[gSizeBytes] = )
: byteArray(rParam)
explicit constexpr UnionStruct(
const PODTypeA(&rParam)[gArraySizeA])
: arrayA(rParam)
explicit constexpr UnionStruct(
const PODTypeB(&rParam)[gArraySizeB])
: arrayB(rParam)
Array<uint8_t, gSizeBytes> byteArray;
Array<PODTypeA, gArraySizeA> arrayA;
Array<PODTypeB, gArraySizeB> arrayB;
;
And here is how I expect to use it:
int main()
PODTypeA[UnionStruct::gArraySizeA] arrayTypeA = 1,2, 3,4;
// construct union from fixed PODTypeA array with 2 elements
UnionStruct foo (arrayTypeA);
The compiler issues the following errors:
g++ -std=c++17 -O2 -Wall -pedantic -pthread main.cpp && ./a.out
main.cpp: In instantiation of 'constexpr Array<T, Size>::Array(const Args& ...) [with Args = unsigned char [2048]; T = unsigned char; long unsigned int Size = 2048]':
main.cpp:34:27: required from here
main.cpp:12:25: error: invalid conversion from 'const unsigned char*' to 'unsigned char' [-fpermissive]
: data args...
^
main.cpp: In instantiation of 'constexpr Array<T, Size>::Array(const Args& ...) [with Args = PODTypeA [2]; T = PODTypeA; long unsigned int Size = 2]':
main.cpp:39:24: required from here
main.cpp:12:25: error: invalid conversion from 'const PODTypeA*' to 'int' [-fpermissive]
main.cpp: In instantiation of 'constexpr Array<T, Size>::Array(const Args& ...) [with Args = PODTypeB [3]; T = PODTypeB; long unsigned int Size = 3]':
main.cpp:44:24: required from here
main.cpp:12:25: error: invalid conversion from 'const PODTypeB*' to 'uint32_t' aka 'unsigned int' [-fpermissive]
main.cpp: In function 'int main()':
main.cpp:54:14: error: expected identifier before numeric constant
PODTypeA[2] arrayTypeA = 1,2, 3,4;
^
main.cpp:54:14: error: expected ']' before numeric constant
PODTypeA[2] arrayTypeA = 1,2, 3,4;
^
]
main.cpp:54:13: error: structured binding declaration cannot have type 'PODTypeA'
PODTypeA[2] arrayTypeA = 1,2, 3,4;
^
main.cpp:54:13: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
main.cpp:54:13: error: empty structured binding declaration
main.cpp:54:17: error: expected initializer before 'arrayTypeA'
PODTypeA[2] arrayTypeA = 1,2, 3,4;
^~~~~~~~~~
main.cpp:56:22: error: 'arrayTypeA' was not declared in this scope
UnionStruct foo (arrayTypeA);
^~~~~~~~~~
main.cpp:56:22: note: suggested alternative: 'gArraySizeA'
UnionStruct foo (arrayTypeA);
^~~~~~~~~~
gArraySizeA
main.cpp:54:13: warning: unused structured binding declaration [-Wunused-variable]
PODTypeA[2] arrayTypeA = 1,2, 3,4;
^
c++11 union c++17 constexpr
IntbyteArray(rParam)
, you are attempting to initialiizebyteArray.data[0]
withrParam
. The former isunsigned char
, the latter isunsigned char*
. Hence the first error.
– Igor Tandetnik
Mar 7 at 4:33
Array declaration goes like this:PODTypeA arrayTypeA[UnionStruct::gArraySizeA]
. You have the bound in the wrong place.
– Igor Tandetnik
Mar 7 at 4:38
add a comment |
I am trying construct a constexpr union which wraps 3 types. The union can contain a raw uint8_t array
or fixed length arrays of PODTypeA
or PODTypeB
. The lengths of these arrays are known at compile time and given by constexpr values.
The POD structures are very simple:
struct PODTypeA
int a;
int b;
;
or
struct PODTypeB
uint32_t a;
uint32_t b;
;
The embedded environment does not have the standard template library available. As such, I cannot use the constexpr std::array<T,N>
which would make things a lot easier.
Shown below is a constexpr Array(const Args&... args)
array implementation, which should function as a constexpr data member to hold array fields.
template <typename T, std::size_t Size>
struct Array
T data[Size];
template <typename ...Args>
constexpr Array(const Args&... args)
: data args...
;
I don't fully understand how the parameter pack expansion works (effectively memcpy(ing) the array via the compiler to the specified union member). If someone could explain that it would be a plus. I found the above Array template parameter pack expander in the checked answer to the following stack overlflow question (where there is also a live example).
I put this in a coliru project but I am having lots of compile issues.
I have 3 constructors for the union, each one of these takes a fixed length array parameter as follows:
constexpr static auto gSizeBytes = 2048;
constexpr static int gArraySizeA = 2;
constexpr static int gArraySizeB = 3;
union UnionStruct
explicit constexpr UnionStruct(
const uint8_t(&rParam)[gSizeBytes] = )
: byteArray(rParam)
explicit constexpr UnionStruct(
const PODTypeA(&rParam)[gArraySizeA])
: arrayA(rParam)
explicit constexpr UnionStruct(
const PODTypeB(&rParam)[gArraySizeB])
: arrayB(rParam)
Array<uint8_t, gSizeBytes> byteArray;
Array<PODTypeA, gArraySizeA> arrayA;
Array<PODTypeB, gArraySizeB> arrayB;
;
And here is how I expect to use it:
int main()
PODTypeA[UnionStruct::gArraySizeA] arrayTypeA = 1,2, 3,4;
// construct union from fixed PODTypeA array with 2 elements
UnionStruct foo (arrayTypeA);
The compiler issues the following errors:
g++ -std=c++17 -O2 -Wall -pedantic -pthread main.cpp && ./a.out
main.cpp: In instantiation of 'constexpr Array<T, Size>::Array(const Args& ...) [with Args = unsigned char [2048]; T = unsigned char; long unsigned int Size = 2048]':
main.cpp:34:27: required from here
main.cpp:12:25: error: invalid conversion from 'const unsigned char*' to 'unsigned char' [-fpermissive]
: data args...
^
main.cpp: In instantiation of 'constexpr Array<T, Size>::Array(const Args& ...) [with Args = PODTypeA [2]; T = PODTypeA; long unsigned int Size = 2]':
main.cpp:39:24: required from here
main.cpp:12:25: error: invalid conversion from 'const PODTypeA*' to 'int' [-fpermissive]
main.cpp: In instantiation of 'constexpr Array<T, Size>::Array(const Args& ...) [with Args = PODTypeB [3]; T = PODTypeB; long unsigned int Size = 3]':
main.cpp:44:24: required from here
main.cpp:12:25: error: invalid conversion from 'const PODTypeB*' to 'uint32_t' aka 'unsigned int' [-fpermissive]
main.cpp: In function 'int main()':
main.cpp:54:14: error: expected identifier before numeric constant
PODTypeA[2] arrayTypeA = 1,2, 3,4;
^
main.cpp:54:14: error: expected ']' before numeric constant
PODTypeA[2] arrayTypeA = 1,2, 3,4;
^
]
main.cpp:54:13: error: structured binding declaration cannot have type 'PODTypeA'
PODTypeA[2] arrayTypeA = 1,2, 3,4;
^
main.cpp:54:13: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
main.cpp:54:13: error: empty structured binding declaration
main.cpp:54:17: error: expected initializer before 'arrayTypeA'
PODTypeA[2] arrayTypeA = 1,2, 3,4;
^~~~~~~~~~
main.cpp:56:22: error: 'arrayTypeA' was not declared in this scope
UnionStruct foo (arrayTypeA);
^~~~~~~~~~
main.cpp:56:22: note: suggested alternative: 'gArraySizeA'
UnionStruct foo (arrayTypeA);
^~~~~~~~~~
gArraySizeA
main.cpp:54:13: warning: unused structured binding declaration [-Wunused-variable]
PODTypeA[2] arrayTypeA = 1,2, 3,4;
^
c++11 union c++17 constexpr
I am trying construct a constexpr union which wraps 3 types. The union can contain a raw uint8_t array
or fixed length arrays of PODTypeA
or PODTypeB
. The lengths of these arrays are known at compile time and given by constexpr values.
The POD structures are very simple:
struct PODTypeA
int a;
int b;
;
or
struct PODTypeB
uint32_t a;
uint32_t b;
;
The embedded environment does not have the standard template library available. As such, I cannot use the constexpr std::array<T,N>
which would make things a lot easier.
Shown below is a constexpr Array(const Args&... args)
array implementation, which should function as a constexpr data member to hold array fields.
template <typename T, std::size_t Size>
struct Array
T data[Size];
template <typename ...Args>
constexpr Array(const Args&... args)
: data args...
;
I don't fully understand how the parameter pack expansion works (effectively memcpy(ing) the array via the compiler to the specified union member). If someone could explain that it would be a plus. I found the above Array template parameter pack expander in the checked answer to the following stack overlflow question (where there is also a live example).
I put this in a coliru project but I am having lots of compile issues.
I have 3 constructors for the union, each one of these takes a fixed length array parameter as follows:
constexpr static auto gSizeBytes = 2048;
constexpr static int gArraySizeA = 2;
constexpr static int gArraySizeB = 3;
union UnionStruct
explicit constexpr UnionStruct(
const uint8_t(&rParam)[gSizeBytes] = )
: byteArray(rParam)
explicit constexpr UnionStruct(
const PODTypeA(&rParam)[gArraySizeA])
: arrayA(rParam)
explicit constexpr UnionStruct(
const PODTypeB(&rParam)[gArraySizeB])
: arrayB(rParam)
Array<uint8_t, gSizeBytes> byteArray;
Array<PODTypeA, gArraySizeA> arrayA;
Array<PODTypeB, gArraySizeB> arrayB;
;
And here is how I expect to use it:
int main()
PODTypeA[UnionStruct::gArraySizeA] arrayTypeA = 1,2, 3,4;
// construct union from fixed PODTypeA array with 2 elements
UnionStruct foo (arrayTypeA);
The compiler issues the following errors:
g++ -std=c++17 -O2 -Wall -pedantic -pthread main.cpp && ./a.out
main.cpp: In instantiation of 'constexpr Array<T, Size>::Array(const Args& ...) [with Args = unsigned char [2048]; T = unsigned char; long unsigned int Size = 2048]':
main.cpp:34:27: required from here
main.cpp:12:25: error: invalid conversion from 'const unsigned char*' to 'unsigned char' [-fpermissive]
: data args...
^
main.cpp: In instantiation of 'constexpr Array<T, Size>::Array(const Args& ...) [with Args = PODTypeA [2]; T = PODTypeA; long unsigned int Size = 2]':
main.cpp:39:24: required from here
main.cpp:12:25: error: invalid conversion from 'const PODTypeA*' to 'int' [-fpermissive]
main.cpp: In instantiation of 'constexpr Array<T, Size>::Array(const Args& ...) [with Args = PODTypeB [3]; T = PODTypeB; long unsigned int Size = 3]':
main.cpp:44:24: required from here
main.cpp:12:25: error: invalid conversion from 'const PODTypeB*' to 'uint32_t' aka 'unsigned int' [-fpermissive]
main.cpp: In function 'int main()':
main.cpp:54:14: error: expected identifier before numeric constant
PODTypeA[2] arrayTypeA = 1,2, 3,4;
^
main.cpp:54:14: error: expected ']' before numeric constant
PODTypeA[2] arrayTypeA = 1,2, 3,4;
^
]
main.cpp:54:13: error: structured binding declaration cannot have type 'PODTypeA'
PODTypeA[2] arrayTypeA = 1,2, 3,4;
^
main.cpp:54:13: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
main.cpp:54:13: error: empty structured binding declaration
main.cpp:54:17: error: expected initializer before 'arrayTypeA'
PODTypeA[2] arrayTypeA = 1,2, 3,4;
^~~~~~~~~~
main.cpp:56:22: error: 'arrayTypeA' was not declared in this scope
UnionStruct foo (arrayTypeA);
^~~~~~~~~~
main.cpp:56:22: note: suggested alternative: 'gArraySizeA'
UnionStruct foo (arrayTypeA);
^~~~~~~~~~
gArraySizeA
main.cpp:54:13: warning: unused structured binding declaration [-Wunused-variable]
PODTypeA[2] arrayTypeA = 1,2, 3,4;
^
c++11 union c++17 constexpr
c++11 union c++17 constexpr
edited Mar 7 at 1:28
johnco3
asked Mar 6 at 23:38
johnco3johnco3
92921737
92921737
IntbyteArray(rParam)
, you are attempting to initialiizebyteArray.data[0]
withrParam
. The former isunsigned char
, the latter isunsigned char*
. Hence the first error.
– Igor Tandetnik
Mar 7 at 4:33
Array declaration goes like this:PODTypeA arrayTypeA[UnionStruct::gArraySizeA]
. You have the bound in the wrong place.
– Igor Tandetnik
Mar 7 at 4:38
add a comment |
IntbyteArray(rParam)
, you are attempting to initialiizebyteArray.data[0]
withrParam
. The former isunsigned char
, the latter isunsigned char*
. Hence the first error.
– Igor Tandetnik
Mar 7 at 4:33
Array declaration goes like this:PODTypeA arrayTypeA[UnionStruct::gArraySizeA]
. You have the bound in the wrong place.
– Igor Tandetnik
Mar 7 at 4:38
Int
byteArray(rParam)
, you are attempting to initialiize byteArray.data[0]
with rParam
. The former is unsigned char
, the latter is unsigned char*
. Hence the first error.– Igor Tandetnik
Mar 7 at 4:33
Int
byteArray(rParam)
, you are attempting to initialiize byteArray.data[0]
with rParam
. The former is unsigned char
, the latter is unsigned char*
. Hence the first error.– Igor Tandetnik
Mar 7 at 4:33
Array declaration goes like this:
PODTypeA arrayTypeA[UnionStruct::gArraySizeA]
. You have the bound in the wrong place.– Igor Tandetnik
Mar 7 at 4:38
Array declaration goes like this:
PODTypeA arrayTypeA[UnionStruct::gArraySizeA]
. You have the bound in the wrong place.– Igor Tandetnik
Mar 7 at 4:38
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55033896%2fconstexpr-union-with-pod-struct-members-using-parameter-pack-expansions%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55033896%2fconstexpr-union-with-pod-struct-members-using-parameter-pack-expansions%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Int
byteArray(rParam)
, you are attempting to initialiizebyteArray.data[0]
withrParam
. The former isunsigned char
, the latter isunsigned char*
. Hence the first error.– Igor Tandetnik
Mar 7 at 4:33
Array declaration goes like this:
PODTypeA arrayTypeA[UnionStruct::gArraySizeA]
. You have the bound in the wrong place.– Igor Tandetnik
Mar 7 at 4:38