From c3bb0f609cdf63dcc17c37a07e2d62ec0bd136e8 Mon Sep 17 00:00:00 2001 From: Marcelo Matus Date: Mon, 27 Feb 2006 16:28:38 +0000 Subject: [PATCH] fix std_map such that is not necessary to use %template() std::pair everytime git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8907 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/python/std_map/example.i | 2 -- Lib/std/std_map.i | 28 ++++++++++++++-------------- 2 files changed, 14 insertions(+), 16 deletions(-) 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") {