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.

  1. should implement tuple_element , tuple_size specializations in namespace std? if not how should implement them?
  2. since i'm not allowed overload stl get function, mean must provide separate get function in own namespace, thereby forcing users write using 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

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -