How to import for mixin contents only.
Taylor Hillegeist via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Mar 10 09:05:26 PST 2016
On Thursday, 10 March 2016 at 16:51:32 UTC, Andrea Fontana wrote:
> On Thursday, 10 March 2016 at 16:20:42 UTC, Taylor Hillegeist
> wrote:
>> I feel like this should do what i want it too. but it doesn't.
>>
>> struct Color_t {
>> static if(1==1){
>> import std.bitmanip:bitfields;
>> immutable string item = bitfields!(
>> uint, "R", 8,
>> uint, "G", 8,
>> uint, "B", 8,
>> uint, "A", 8);
>> }
>> mixin(item);
>> }
>
> I wonder if compiler is smart enaugh to undestand that
> dependency is not needed at runtime in this case:
>
> http://dpaste.dzfl.pl/fd3bc2a839a3
well the latest gdc isnt smart enough.
immutable(string) BF(){
if(!__ctfe)
assert(0);
import std.bitmanip:bitfields;
return bitfields!(
uint, "R", 8,
uint, "G", 8,
uint, "B", 8,
uint, "A", 8);
}
struct Color_t {
mixin(BF());
}
is a fair try as well. but neither work.
More information about the Digitalmars-d-learn
mailing list