This feature is very good, directly to the example, if I want to design a class, cachedfetcher internal may use Std::map may also use Std::unordered_map, may be other map, how to design it? It's hard not to c++11 the template before it gets longer. Because the template parameter of map is not only key,value two Ah, there are some default parameters of the templates parameter ...
??
Template<typename _key, TypeName _value,
Template<class _kty, Class _ty, typename...> class _map = std::unordered_map>
Class Cachedfetcher
{
Public
typedef _key Key;
typedef _value Value;
typedef _map<key, value> Map;
typedef typename Map::iterator iterator;
typedef typename Map::const_iterator Const_iterator;
??
Private
Map _map;
};
??
??
??
Another better feature
Template<typename _key, TypeName _value,
Template<class _kty, Class _ty, typename...> class _map = std::map>
Class Lrumap
{
};
Template <typename Key, TypeName Value, typename...>
using Lruhashmap = Lrumap<key, Value, std::unordered_map>;
??
??
A useful feature of the last non-template, the constructor for reusing base classes
??
Class Featurevector:public Vector
{
Public
~featurevector () = default;
Featurevector (featurevector&&) = default;
featurevector& operator = (featurevector&&) = default;
Featurevector (const featurevector&) = default;
featurevector& operator = (const featurevector&) = default;
??
#ifndef Gccxml
Using Vector::vector;
#endif
}
??
C++11 template new Features-template for variable-length parameters