0
namespace Ubpa::USRefl {
   // [summary]
   // attribute for field, class, enum
   // [member]
   // T value (T == void -> no value)
   template<typename Name, typename T>
   struct Attr;

   template<typename Name>
   Attr(Name)->Attr<Name, void>;

   template<typename Name, typename Value>
   Attr(Name, Value)->Attr<Name, Value>;
}

I am a beginner from C++11. I hope someone can explain the meaning of the above code in an easy-to-understand manner.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Vigil
  • 17
  • 1
  • 1
  • 1
    Which parts of the code do you understand now, and what can we help you with? Can you provide some context on this code and what you’re aiming to do with it? – templatetypedef Aug 06 '22 at 05:57
  • Read https://en.cppreference.com/w/cpp/language/class_template_argument_deduction – Passer By Aug 06 '22 at 05:57
  • (I’m asking because there’s namespaces, templates, and template deduction guides here and I’m not sure which one you’d like help with. ^_^) – templatetypedef Aug 06 '22 at 06:13
  • I understand namespace nesting now namespace::Ubpa::USRefl I don't understand what the definition of{ template struct Attr} does.and Attr(Name)->Attr; – Vigil Aug 06 '22 at 06:23
  • @Vigil `template struct Attr;` is just a declaration of a class template. The other declarations in the namespace are deduction guides as explained in the linked duplicate. – user17732522 Aug 06 '22 at 08:44
  • @user17732522 I still have one last confusion: struct attr; There is nothing in this structure. Is it meaningful to deduce its type? – Vigil Aug 06 '22 at 09:10
  • @Vigil It is just a (forward-)declaration of the class template. The definition is somewhere else. (You are not showing it.) – user17732522 Aug 06 '22 at 13:36

0 Answers0