How to import for mixin contents only.
Mike Parker via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Mar 9 20:56:52 PST 2016
On Thursday, 10 March 2016 at 04:07:54 UTC, Taylor Hillegeist
wrote:
> So i want bitfields for just a little bit. but i dont want its
> dependencies. How is it done. I have tried this. but it doesnt
> seem to work on gdc. :(
>
> struct Color_t {
> static if(__ctfe){
> import std.bitmanip:bitfields;
> }
> mixin(bitfields!(
> uint, "R", 8,
> uint, "G", 8,
> uint, "B", 8,
> uint, "A", 8));
> }
__ctfe is a runtime construct, not compile-time. It cannot be
used with static if. More over, it's only available *inside* a
function that is currently being executed in a compile-time
context. It has no role outside of that.
What problem are you trying to solve here? I mean, what is the
problem with whatever dependencies std.bitmanip:bitfields has
that makes you only want to import it during compilation?
More information about the Digitalmars-d-learn
mailing list