c++ - How should you implement STL features for custom classes? -
i'm implementing tuple-like class, call mytuple
, , have stl features, namely tuple_element
, tuple_size
, , get
.
- should implement
tuple_element
,tuple_size
specializations innamespace std
? if not how should implement them? - since i'm not allowed overload stl
get
function, mean must provide separateget
function in own namespace, thereby forcing users writeusing std::get;
?
recall there ain't no such thing partial specialization of function templates. can't partially specialize std::tuple_element
et al class.
normally, define free-standing functions logically part of class' interface in same namespace class itself. can rely on argument-dependent lookup find them. std::get found same mechanism - users of library not in fact forced write using std::get
.
Comments
Post a Comment