@@ -480,25 +480,57 @@ def is_fundamental(type_):
480480 (cpptypes .volatile_t , cpptypes .const_t ))
481481
482482
483+ def _normalize (string ):
484+ return string .replace (' ' , '' ).replace ("::std" , "std" )
485+
486+
487+ def _normalize_equivalences (equivalences ):
488+ return [_normalize (eq ) for eq in equivalences ]
489+
490+
483491string_equivalences = [
484492 (
485- '::std::basic_string<char,std::char_traits<char>,'
486- 'std::allocator<char>>' ),
487- '::std::basic_string<char>' , '::std::string' ]
493+ 'std::basic_string<char, std::char_traits<char>, '
494+ 'std::allocator<char>>'
495+ ),
496+ 'std::basic_string<char>' ,
497+ 'std::string'
498+ ]
488499
489500wstring_equivalences = [
490501 (
491- '::std::basic_string<wchar_t,std::char_traits<wchar_t>,' +
492- 'std::allocator<wchar_t>>' ),
493- '::std::basic_string<wchar_t>' , '::std::wstring' ]
502+ 'std::basic_string<wchar_t, std::char_traits<wchar_t>, '
503+ 'std::allocator<wchar_t>>'
504+ ),
505+ 'std::basic_string<wchar_t>' ,
506+ 'std::wstring'
507+ ]
494508
495509ostream_equivalences = [
496- '::std::basic_ostream<char,std::char_traits<char>>' ,
497- '::std::basic_ostream<char>' , '::std::ostream' ]
510+ 'std::basic_ostream<char, std::char_traits<char>>' ,
511+ 'std::basic_ostream<char>' ,
512+ 'std::ostream'
513+ ]
498514
499515wostream_equivalences = [
500- '::std::basic_ostream<wchar_t,std::char_traits<wchar_t>>' ,
501- '::std::basic_ostream<wchar_t>' , '::std::wostream' ]
516+ 'std::basic_ostream<wchar_t, std::char_traits<wchar_t>>' ,
517+ 'std::basic_ostream<wchar_t>' ,
518+ 'std::wostream'
519+ ]
520+
521+
522+ normalized_string_equivalences = _normalize_equivalences (
523+ string_equivalences
524+ )
525+ normalized_wstring_equivalences = _normalize_equivalences (
526+ wstring_equivalences
527+ )
528+ normalized_ostream_equivalences = _normalize_equivalences (
529+ ostream_equivalences
530+ )
531+ normalized_wostream_equivalences = _normalize_equivalences (
532+ wostream_equivalences
533+ )
502534
503535
504536def is_std_string (type_ ):
@@ -508,12 +540,12 @@ def is_std_string(type_):
508540 """
509541
510542 if isinstance (type_ , str ):
511- return type_ in string_equivalences
543+ return _normalize ( type_ ) in normalized_string_equivalences
512544
513545 type_ = remove_alias (type_ )
514546 type_ = remove_reference (type_ )
515547 type_ = remove_cv (type_ )
516- return type_ .decl_string . replace ( ' ' , '' ) in string_equivalences
548+ return _normalize ( type_ .decl_string ) in normalized_string_equivalences
517549
518550
519551def is_std_wstring (type_ ):
@@ -523,12 +555,12 @@ def is_std_wstring(type_):
523555 """
524556
525557 if isinstance (type_ , str ):
526- return type_ in wstring_equivalences
558+ return _normalize ( type_ ) in normalized_wstring_equivalences
527559
528560 type_ = remove_alias (type_ )
529561 type_ = remove_reference (type_ )
530562 type_ = remove_cv (type_ )
531- return type_ .decl_string . replace ( ' ' , '' ) in wstring_equivalences
563+ return _normalize ( type_ .decl_string ) in normalized_wstring_equivalences
532564
533565
534566def is_std_ostream (type_ ):
@@ -538,12 +570,12 @@ def is_std_ostream(type_):
538570 """
539571
540572 if isinstance (type_ , str ):
541- return type_ in ostream_equivalences
573+ return _normalize ( type_ ) in normalized_ostream_equivalences
542574
543575 type_ = remove_alias (type_ )
544576 type_ = remove_reference (type_ )
545577 type_ = remove_cv (type_ )
546- return type_ .decl_string . replace ( ' ' , '' ) in ostream_equivalences
578+ return _normalize ( type_ .decl_string ) in normalized_ostream_equivalences
547579
548580
549581def is_std_wostream (type_ ):
@@ -553,9 +585,9 @@ def is_std_wostream(type_):
553585 """
554586
555587 if isinstance (type_ , str ):
556- return type_ in wostream_equivalences
588+ return _normalize ( type_ ) in normalized_wostream_equivalences
557589
558590 type_ = remove_alias (type_ )
559591 type_ = remove_reference (type_ )
560592 type_ = remove_cv (type_ )
561- return type_ .decl_string . replace ( ' ' , '' ) in wostream_equivalences
593+ return _normalize ( type_ .decl_string ) in normalized_wostream_equivalences
0 commit comments