<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Don't know if this is what you want but:<br>
<br>
struct Marked {}<br>
struct Attrs (T...) {}<br>
<br>
auto bar ()<br>
{<br>
@Marked int i;<br>
return Attrs!(__traits(getAttributes, i))();<br>
}<br>
<br>
void main ()<br>
{<br>
writeln(bar()); // prints Attrs!(Marked)()<br>
}</blockquote><div><br></div><div>I just want to be able to return an attributed something. How can a function return something that's attributed?</div><div><br></div><div>IIUC what Walter said, a function cannot return an attributed value: any internal symbol can be attributed, but these cannot get out.</div>
<div>I can create can attributed value to 'catch' what a function returns, but not automatically:</div><div><br></div><div>??? attributedInt()</div><div>{</div><div> @("Hello") int i = 1;</div><div> return i;</div>
<div>}</div><div><br></div><div>void main()</div><div>{</div><div> ??? j = attributedInt();</div><div> // How to have j get the @("Hello") attribute?</div><div>}</div><div><br></div><div>The only way would be what you suggest:</div>
<div><br></div><div>- extract the attributes from the internal i</div><div>- store them in a specially-crafted struct</div><div>- return that</div><div>- in the external code, catch the returned struct</div><div>- extract the artificially stored attributes</div>
<div>- generate a new value with the same attributes.</div><div><br></div><div><br></div><div>Ugh.</div><div><br></div><div><br></div></div>