@@ -480,40 +480,60 @@ 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>>' ,
510+ '::std::basic_ostream<char, std::char_traits<char>>' ,
497511 '::std::basic_ostream<char>' , '::std::ostream' ]
498512
499513wostream_equivalences = [
500- '::std::basic_ostream<wchar_t,std::char_traits<wchar_t>>' ,
514+ '::std::basic_ostream<wchar_t, std::char_traits<wchar_t>>' ,
501515 '::std::basic_ostream<wchar_t>' , '::std::wostream' ]
502516
503517
518+ normalized_string_equivalences = _normalize_equivalences (string_equivalences )
519+ normalized_wstring_equivalences = _normalize_equivalences (wstring_equivalences )
520+ normalized_ostream_equivalences = _normalize_equivalences (ostream_equivalences )
521+ normalized_wostream_equivalences = _normalize_equivalences (wostream_equivalences )
522+
523+
504524def is_std_string (type_ ):
505525 """
506526 Returns True, if type represents C++ `std::string`, False otherwise.
507527
508528 """
509529
510530 if isinstance (type_ , str ):
511- return type_ in string_equivalences
531+ return _normalize ( type_ ) in normalized_string_equivalences
512532
513533 type_ = remove_alias (type_ )
514534 type_ = remove_reference (type_ )
515535 type_ = remove_cv (type_ )
516- return type_ .decl_string . replace ( ' ' , '' ) in string_equivalences
536+ return _normalize ( type_ .decl_string ) in normalized_string_equivalences
517537
518538
519539def is_std_wstring (type_ ):
@@ -523,12 +543,12 @@ def is_std_wstring(type_):
523543 """
524544
525545 if isinstance (type_ , str ):
526- return type_ in wstring_equivalences
546+ return _normalize ( type_ ) in normalized_wstring_equivalences
527547
528548 type_ = remove_alias (type_ )
529549 type_ = remove_reference (type_ )
530550 type_ = remove_cv (type_ )
531- return type_ .decl_string . replace ( ' ' , '' ) in wstring_equivalences
551+ return _normalize ( type_ .decl_string ) in normalized_wstring_equivalences
532552
533553
534554def is_std_ostream (type_ ):
@@ -538,12 +558,12 @@ def is_std_ostream(type_):
538558 """
539559
540560 if isinstance (type_ , str ):
541- return type_ in ostream_equivalences
561+ return _normalize ( type_ ) in normalized_ostream_equivalences
542562
543563 type_ = remove_alias (type_ )
544564 type_ = remove_reference (type_ )
545565 type_ = remove_cv (type_ )
546- return type_ .decl_string . replace ( ' ' , '' ) in ostream_equivalences
566+ return _normalize ( type_ .decl_string ) in normalized_ostream_equivalences
547567
548568
549569def is_std_wostream (type_ ):
@@ -553,9 +573,9 @@ def is_std_wostream(type_):
553573 """
554574
555575 if isinstance (type_ , str ):
556- return type_ in wostream_equivalences
576+ return _normalize ( type_ ) in normalized_wostream_equivalences
557577
558578 type_ = remove_alias (type_ )
559579 type_ = remove_reference (type_ )
560580 type_ = remove_cv (type_ )
561- return type_ .decl_string . replace ( ' ' , '' ) in wostream_equivalences
581+ return _normalize ( type_ .decl_string ) in normalized_wostream_equivalences
0 commit comments