Advertisement
Guest User

Untitled

a guest
May 13th, 2019
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
D 0.35 KB | None | 0 0
  1. template hasProperty(alias T, string property){
  2.     static if( __traits( compiles, { auto test = T.init; } ) )
  3.     {
  4.         enum bool hasProperty = is(typeof({
  5.             mixin(`auto property = T.init.` ~ property ~ `;`);
  6.         }));
  7.     }
  8.     else
  9.     {
  10.         enum bool hasProperty = is(typeof({
  11.             mixin(`auto property = T.` ~ property ~ `;`);
  12.         }));
  13.     }
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement