diff --git a/Examples/python/std_map/example.i b/Examples/python/std_map/example.i index 1dcf8a536..36354a882 100644 --- a/Examples/python/std_map/example.i +++ b/Examples/python/std_map/example.i @@ -12,8 +12,6 @@ /* instantiate the required template specializations */ namespace std { /* remember to instantiate the key,value pair! */ - %template() pair; - %template() pair; %template(DoubleMap) map; %template() map; } diff --git a/Lib/std/std_map.i b/Lib/std/std_map.i index d63a08084..487223604 100644 --- a/Lib/std/std_map.i +++ b/Lib/std/std_map.i @@ -34,20 +34,6 @@ %enddef -// **** Note **** -// -// If you are going to use a map, you need to instantiate both the -// map and the pair class: -// -// %template(pair_ii) std::pair; -// %template(map_ii) std::map; -// -// or -// -// %template() std::pair; -// %template(map_ii) std::map; -// -// **** Note **** // ------------------------------------------------------------------------ // std::map // @@ -99,6 +85,20 @@ namespace std { %traits_swigtype(_Key); %traits_swigtype(_Tp); + %fragment(SWIG_Traits_frag(std::pair< _Key, _Tp >), "header", + fragment=SWIG_Traits_frag(_Key), + fragment=SWIG_Traits_frag(_Tp), + fragment="StdPairTraits") { + namespace swig { + template <> struct traits > { + typedef pointer_category category; + static const char* type_name() { + return "std::pair<" #_Key "," #_Tp " >"; + } + }; + } + } + %fragment(SWIG_Traits_frag(std::map<_Key, _Tp, _Compare, _Alloc >), "header", fragment=SWIG_Traits_frag(std::pair<_Key, _Tp >), fragment="StdMapTraits") {