digitalmars.D.learn - How to get field default value at CT
- Mike B Johnson (6/6) May 06 2017 I'd like to get the value assign to a field at CT.
- Stanislav Blinov (15/21) May 06 2017 Use the .init property:
I'd like to get the value assign to a field at CT.
struct
{
int x = 3434;
}
I'd like to get the assigned "value" 3434 for x at CT.
May 06 2017
On Saturday, 6 May 2017 at 21:40:24 UTC, Mike B Johnson wrote:
I'd like to get the value assign to a field at CT.
struct
{
int x = 3434;
}
I'd like to get the assigned "value" 3434 for x at CT.
Use the .init property:
struct S
{
int x = 3434;
}
unittest
{
static assert(S.init.x == 3434);
}
void main()
{
enum xAtCT = S.init.x;
pragma(msg, xAtCT);
}
May 06 2017








Stanislav Blinov <stanislav.blinov gmail.com>