Training courses

Kernel and Embedded Linux

Bootlin training courses

Embedded Linux, kernel,
Yocto Project, Buildroot, real-time,
graphics, boot time, debugging...

Bootlin logo

Elixir Cross Referencer

   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
// Debugging string implementation -*- C++ -*-

// Copyright (C) 2003-2020 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.

/** @file debug/string
 *  This file is a GNU debug extension to the Standard C++ Library.
 */

#ifndef _GLIBCXX_DEBUG_STRING
#define _GLIBCXX_DEBUG_STRING 1

#pragma GCC system_header

#include <string>
#include <debug/safe_sequence.h>
#include <debug/safe_container.h>
#include <debug/safe_iterator.h>

#define _GLIBCXX_DEBUG_VERIFY_STR_COND_AT(_Cond,_File,_Line,_Func)	\
  if (! (_Cond))							\
    __gnu_debug::_Error_formatter::_S_at(_File, _Line, _Func)		\
      ._M_message(#_Cond)._M_error()

namespace __gnu_debug
{
  /** Checks that __s is non-NULL or __n == 0, and then returns __s. */
  template<typename _CharT, typename _Integer>
    inline const _CharT*
    __check_string(const _CharT* __s,
		   _Integer __n __attribute__((__unused__)),
		   const char* __file __attribute__((__unused__)),
		   unsigned int __line __attribute__((__unused__)),
		   const char* __function __attribute__((__unused__)))
    {
#ifdef _GLIBCXX_DEBUG_PEDANTIC
      _GLIBCXX_DEBUG_VERIFY_STR_COND_AT(__s != 0 || __n == 0,
					__file, __line, __function);
#endif
      return __s;
    }

  /** Checks that __s is non-NULL and then returns __s. */
  template<typename _CharT>
    inline const _CharT*
    __check_string(const _CharT* __s,
		   const char* __file __attribute__((__unused__)),
		   unsigned int __line __attribute__((__unused__)),
		   const char* __function __attribute__((__unused__)))
    {
#ifdef _GLIBCXX_DEBUG_PEDANTIC
      _GLIBCXX_DEBUG_VERIFY_STR_COND_AT(__s != 0,
					__file, __line, __function);
#endif
      return __s;
    }

#define __glibcxx_check_string_n_constructor(_Str, _Size) \
  __check_string(_Str, _Size, __FILE__, __LINE__, __PRETTY_FUNCTION__)

#define __glibcxx_check_string_constructor(_Str) \
  __check_string(_Str, __FILE__, __LINE__, __PRETTY_FUNCTION__)

  /// Class std::basic_string with safety/checking/debug instrumentation.
  template<typename _CharT, typename _Traits = std::char_traits<_CharT>,
	   typename _Allocator = std::allocator<_CharT> >
    class basic_string
      : public __gnu_debug::_Safe_container<
	  basic_string<_CharT, _Traits, _Allocator>,
	  _Allocator, _Safe_sequence, bool(_GLIBCXX_USE_CXX11_ABI)>,
	public std::basic_string<_CharT, _Traits, _Allocator>
    {
      typedef std::basic_string<_CharT, _Traits, _Allocator>	_Base;
      typedef __gnu_debug::_Safe_container<
	basic_string, _Allocator, _Safe_sequence, bool(_GLIBCXX_USE_CXX11_ABI)>
      _Safe;

      template<typename _ItT, typename _SeqT, typename _CatT>
	friend class ::__gnu_debug::_Safe_iterator;

      // type used for positions in insert, erase etc.
      typedef __gnu_debug::_Safe_iterator<
	typename _Base::__const_iterator, basic_string> __const_iterator;

    public:
      // types:
      typedef _Traits					traits_type;
      typedef typename _Traits::char_type		value_type;
      typedef _Allocator				allocator_type;
      typedef typename _Base::size_type			size_type;
      typedef typename _Base::difference_type		difference_type;
      typedef typename _Base::reference			reference;
      typedef typename _Base::const_reference		const_reference;
      typedef typename _Base::pointer			pointer;
      typedef typename _Base::const_pointer		const_pointer;

      typedef __gnu_debug::_Safe_iterator<
	typename _Base::iterator, basic_string>		iterator;
      typedef __gnu_debug::_Safe_iterator<
	typename _Base::const_iterator, basic_string>	const_iterator;

      typedef std::reverse_iterator<iterator>		reverse_iterator;
      typedef std::reverse_iterator<const_iterator>	const_reverse_iterator;

      using _Base::npos;

      basic_string()
	_GLIBCXX_NOEXCEPT_IF(std::is_nothrow_default_constructible<_Base>::value)
	: _Base() { }

      // 21.3.1 construct/copy/destroy:
      explicit
      basic_string(const _Allocator& __a) _GLIBCXX_NOEXCEPT
      : _Base(__a) { }

#if __cplusplus < 201103L
      basic_string(const basic_string& __str)
      : _Base(__str) { }

      ~basic_string() { }
#else
      basic_string(const basic_string&) = default;
      basic_string(basic_string&&) = default;

      basic_string(std::initializer_list<_CharT> __l,
		   const _Allocator& __a = _Allocator())
      : _Base(__l, __a)
      { }

#if _GLIBCXX_USE_CXX11_ABI
      basic_string(const basic_string& __s, const _Allocator& __a)
      : _Base(__s, __a) { }

      basic_string(basic_string&& __s, const _Allocator& __a)
      : _Base(std::move(__s), __a) { }
#endif

      ~basic_string() = default;

      // Provides conversion from a normal-mode string to a debug-mode string
      basic_string(_Base&& __base) noexcept
      : _Base(std::move(__base)) { }
#endif // C++11

      // Provides conversion from a normal-mode string to a debug-mode string
      basic_string(const _Base& __base)
      : _Base(__base) { }

      // _GLIBCXX_RESOLVE_LIB_DEFECTS
      // 42. string ctors specify wrong default allocator
      basic_string(const basic_string& __str, size_type __pos,
		   size_type __n = _Base::npos,
		   const _Allocator& __a = _Allocator())
      : _Base(__str, __pos, __n, __a) { }

      basic_string(const _CharT* __s, size_type __n,
		   const _Allocator& __a = _Allocator())
      : _Base(__glibcxx_check_string_n_constructor(__s, __n), __n, __a) { }

      basic_string(const _CharT* __s, const _Allocator& __a = _Allocator())
      : _Base(__glibcxx_check_string_constructor(__s), __a)
      { this->assign(__s); }

      basic_string(size_type __n, _CharT __c,
		   const _Allocator& __a = _Allocator())
      : _Base(__n, __c, __a) { }

      template<typename _InputIterator>
	basic_string(_InputIterator __begin, _InputIterator __end,
		     const _Allocator& __a = _Allocator())
	: _Base(__gnu_debug::__base(
		  __glibcxx_check_valid_constructor_range(__begin, __end)),
		__gnu_debug::__base(__end), __a) { }

#if __cplusplus < 201103L
      basic_string&
      operator=(const basic_string& __str)
      {
	this->_M_safe() = __str;
	_M_base() = __str;
	return *this;
      }
#else
      basic_string&
      operator=(const basic_string&) = default;

      basic_string&
      operator=(basic_string&&) = default;
#endif

      basic_string&
      operator=(const _CharT* __s)
      {
	__glibcxx_check_string(__s);
	_M_base() = __s;
	this->_M_invalidate_all();
	return *this;
      }

      basic_string&
      operator=(_CharT __c)
      {
	_M_base() = __c;
	this->_M_invalidate_all();
	return *this;
      }

#if __cplusplus >= 201103L
      basic_string&
      operator=(std::initializer_list<_CharT> __l)
      {
	_M_base() = __l;
	this->_M_invalidate_all();
	return *this;
      }
#endif // C++11

      // 21.3.2 iterators:
      iterator
      begin() // _GLIBCXX_NOEXCEPT
      { return iterator(_Base::begin(), this); }

      const_iterator
      begin() const _GLIBCXX_NOEXCEPT
      { return const_iterator(_Base::begin(), this); }

      iterator
      end() // _GLIBCXX_NOEXCEPT
      { return iterator(_Base::end(), this); }

      const_iterator
      end() const _GLIBCXX_NOEXCEPT
      { return const_iterator(_Base::end(), this); }

      reverse_iterator
      rbegin() // _GLIBCXX_NOEXCEPT
      { return reverse_iterator(end()); }

      const_reverse_iterator
      rbegin() const _GLIBCXX_NOEXCEPT
      { return const_reverse_iterator(end()); }

      reverse_iterator
      rend() // _GLIBCXX_NOEXCEPT
      { return reverse_iterator(begin()); }

      const_reverse_iterator
      rend() const _GLIBCXX_NOEXCEPT
      { return const_reverse_iterator(begin()); }

#if __cplusplus >= 201103L
      const_iterator
      cbegin() const noexcept
      { return const_iterator(_Base::begin(), this); }

      const_iterator
      cend() const noexcept
      { return const_iterator(_Base::end(), this); }

      const_reverse_iterator
      crbegin() const noexcept
      { return const_reverse_iterator(end()); }

      const_reverse_iterator
      crend() const noexcept
      { return const_reverse_iterator(begin()); }
#endif

      // 21.3.3 capacity:
      using _Base::size;
      using _Base::length;
      using _Base::max_size;

      void
      resize(size_type __n, _CharT __c)
      {
	_Base::resize(__n, __c);
	this->_M_invalidate_all();
      }

      void
      resize(size_type __n)
      { this->resize(__n, _CharT()); }

#if __cplusplus >= 201103L
      void
      shrink_to_fit() noexcept
      {
	if (capacity() > size())
	  {
	    __try
	      {
		reserve(0);
		this->_M_invalidate_all();
	      }
	    __catch(...)
	      { }
	  }
      }
#endif

      using _Base::capacity;
      using _Base::reserve;

      void
      clear() // _GLIBCXX_NOEXCEPT
      {
	_Base::clear();
	this->_M_invalidate_all();
      }

      using _Base::empty;

      // 21.3.4 element access:
      const_reference
      operator[](size_type __pos) const _GLIBCXX_NOEXCEPT
      {
	_GLIBCXX_DEBUG_VERIFY(__pos <= this->size(),
			      _M_message(__gnu_debug::__msg_subscript_oob)
			      ._M_sequence(*this, "this")
			      ._M_integer(__pos, "__pos")
			      ._M_integer(this->size(), "size"));
	return _M_base()[__pos];
      }

      reference
      operator[](size_type __pos) // _GLIBCXX_NOEXCEPT
      {
#if __cplusplus < 201103L && defined(_GLIBCXX_DEBUG_PEDANTIC)
	__glibcxx_check_subscript(__pos);
#else
	// as an extension v3 allows s[s.size()] when s is non-const.
	_GLIBCXX_DEBUG_VERIFY(__pos <= this->size(),
			      _M_message(__gnu_debug::__msg_subscript_oob)
			      ._M_sequence(*this, "this")
			      ._M_integer(__pos, "__pos")
			      ._M_integer(this->size(), "size"));
#endif
	return _M_base()[__pos];
      }

      using _Base::at;

#if __cplusplus >= 201103L
      using _Base::front;
      using _Base::back;
#endif

      // 21.3.5 modifiers:
      basic_string&
      operator+=(const basic_string& __str)
      {
	_M_base() += __str;
	this->_M_invalidate_all();
	return *this;
      }

      basic_string&
      operator+=(const _CharT* __s)
      {
	__glibcxx_check_string(__s);
	_M_base() += __s;
	this->_M_invalidate_all();
	return *this;
      }

      basic_string&
      operator+=(_CharT __c)
      {
	_M_base() += __c;
	this->_M_invalidate_all();
	return *this;
      }

#if __cplusplus >= 201103L
      basic_string&
      operator+=(std::initializer_list<_CharT> __l)
      {
	_M_base() += __l;
	this->_M_invalidate_all();
	return *this;
      }
#endif // C++11

      basic_string&
      append(const basic_string& __str)
      {
	_Base::append(__str);
	this->_M_invalidate_all();
	return *this;
      }

      basic_string&
      append(const basic_string& __str, size_type __pos, size_type __n)
      {
	_Base::append(__str, __pos, __n);
	this->_M_invalidate_all();
	return *this;
      }

      basic_string&
      append(const _CharT* __s, size_type __n)
      {
	__glibcxx_check_string_len(__s, __n);
	_Base::append(__s, __n);
	this->_M_invalidate_all();
	return *this;
      }

      basic_string&
      append(const _CharT* __s)
      {
	__glibcxx_check_string(__s);
	_Base::append(__s);
	this->_M_invalidate_all();
	return *this;
      }

      basic_string&
      append(size_type __n, _CharT __c)
      {
	_Base::append(__n, __c);
	this->_M_invalidate_all();
	return *this;
      }

      template<typename _InputIterator>
	basic_string&
	append(_InputIterator __first, _InputIterator __last)
	{
	  typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist;
	  __glibcxx_check_valid_range2(__first, __last, __dist);

	  if (__dist.second >= __dp_sign)
	    _Base::append(__gnu_debug::__unsafe(__first),
			  __gnu_debug::__unsafe(__last));
	  else
	    _Base::append(__first, __last);

	  this->_M_invalidate_all();
	  return *this;
	}

      // _GLIBCXX_RESOLVE_LIB_DEFECTS
      // 7. string clause minor problems
      void
      push_back(_CharT __c)
      {
	_Base::push_back(__c);
	this->_M_invalidate_all();
      }

      basic_string&
      assign(const basic_string& __x)
      {
	_Base::assign(__x);
	this->_M_invalidate_all();
	return *this;
      }

#if __cplusplus >= 201103L
      basic_string&
      assign(basic_string&& __x)
      noexcept(noexcept(std::declval<_Base&>().assign(std::move(__x))))
      {
	_Base::assign(std::move(__x));
	this->_M_invalidate_all();
	return *this;
      }
#endif // C++11

      basic_string&
      assign(const basic_string& __str, size_type __pos, size_type __n)
      {
	_Base::assign(__str, __pos, __n);
	this->_M_invalidate_all();
	return *this;
      }

      basic_string&
      assign(const _CharT* __s, size_type __n)
      {
	__glibcxx_check_string_len(__s, __n);
	_Base::assign(__s, __n);
	this->_M_invalidate_all();
	return *this;
      }

      basic_string&
      assign(const _CharT* __s)
      {
	__glibcxx_check_string(__s);
	_Base::assign(__s);
	this->_M_invalidate_all();
	return *this;
      }

      basic_string&
      assign(size_type __n, _CharT __c)
      {
	_Base::assign(__n, __c);
	this->_M_invalidate_all();
	return *this;
      }

      template<typename _InputIterator>
	basic_string&
	assign(_InputIterator __first, _InputIterator __last)
	{
	  typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist;
	  __glibcxx_check_valid_range2(__first, __last, __dist);

	  if (__dist.second >= __dp_sign)
	    _Base::assign(__gnu_debug::__unsafe(__first),
			  __gnu_debug::__unsafe(__last));
	  else
	    _Base::assign(__first, __last);

	  this->_M_invalidate_all();
	  return *this;
	}

#if __cplusplus >= 201103L
      basic_string&
      assign(std::initializer_list<_CharT> __l)
      {
	_Base::assign(__l);
	this->_M_invalidate_all();
	return *this;
      }
#endif // C++11

      basic_string&
      insert(size_type __pos1, const basic_string& __str)
      {
	_Base::insert(__pos1, __str);
	this->_M_invalidate_all();
	return *this;
      }

      basic_string&
      insert(size_type __pos1, const basic_string& __str,
	     size_type __pos2, size_type __n)
      {
	_Base::insert(__pos1, __str, __pos2, __n);
	this->_M_invalidate_all();
	return *this;
      }

      basic_string&
      insert(size_type __pos, const _CharT* __s, size_type __n)
      {
	__glibcxx_check_string(__s);
	_Base::insert(__pos, __s, __n);
	this->_M_invalidate_all();
	return *this;
      }

      basic_string&
      insert(size_type __pos, const _CharT* __s)
      {
	__glibcxx_check_string(__s);
	_Base::insert(__pos, __s);
	this->_M_invalidate_all();
	return *this;
      }

      basic_string&
      insert(size_type __pos, size_type __n, _CharT __c)
      {
	_Base::insert(__pos, __n, __c);
	this->_M_invalidate_all();
	return *this;
      }

      iterator
      insert(__const_iterator __p, _CharT __c)
      {
	__glibcxx_check_insert(__p);
	typename _Base::iterator __res = _Base::insert(__p.base(), __c);
	this->_M_invalidate_all();
	return iterator(__res, this);
      }

#if __cplusplus >= 201103L
      iterator
      insert(const_iterator __p, size_type __n, _CharT __c)
      {
	__glibcxx_check_insert(__p);
#if _GLIBCXX_USE_CXX11_ABI
	typename _Base::iterator __res = _Base::insert(__p.base(), __n, __c);
#else
	const size_type __offset = __p.base() - _Base::cbegin();
	_Base::insert(_Base::begin() + __offset, __n, __c);
	typename _Base::iterator __res = _Base::begin() + __offset;
#endif
	this->_M_invalidate_all();
	return iterator(__res, this);
      }
#else
      void
      insert(iterator __p, size_type __n, _CharT __c)
      {
	__glibcxx_check_insert(__p);
	_Base::insert(__p.base(), __n, __c);
	this->_M_invalidate_all();
      }
#endif

      template<typename _InputIterator>
	iterator
	insert(__const_iterator __p,
	       _InputIterator __first, _InputIterator __last)
	{
	  typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist;
	  __glibcxx_check_insert_range(__p, __first, __last, __dist);

	  typename _Base::iterator __res;
#if _GLIBCXX_USE_CXX11_ABI && __cplusplus >= 201103
	  if (__dist.second >= __dp_sign)
	    __res = _Base::insert(__p.base(), __gnu_debug::__unsafe(__first),
				  __gnu_debug::__unsafe(__last));
	  else
	    __res = _Base::insert(__p.base(), __first, __last);
#else
	  const size_type __offset = __p.base() - _Base::begin();
	  _Base::insert(__p.base(), __first, __last);
	  __res = _Base::begin() + __offset;
#endif
	  this->_M_invalidate_all();
	  return iterator(__res, this);
	}

#if __cplusplus >= 201103L
      iterator
      insert(const_iterator __p, std::initializer_list<_CharT> __l)
      {
	__glibcxx_check_insert(__p);
#if _GLIBCXX_USE_CXX11_ABI
	const auto __res = _Base::insert(__p.base(), __l);
#else
	const size_type __offset = __p.base() - _Base::cbegin();
	_Base::insert(_Base::begin() + __offset, __l);
	auto __res = _Base::begin() + __offset;
#endif
	this->_M_invalidate_all();
	return iterator(__res, this);
      }
#endif // C++11

      basic_string&
      erase(size_type __pos = 0, size_type __n = _Base::npos)
      {
	_Base::erase(__pos, __n);
	this->_M_invalidate_all();
	return *this;
      }

      iterator
      erase(iterator __position)
      {
	__glibcxx_check_erase(__position);
	typename _Base::iterator __res = _Base::erase(__position.base());
	this->_M_invalidate_all();
	return iterator(__res, this);
      }

      iterator
      erase(iterator __first, iterator __last)
      {
	// _GLIBCXX_RESOLVE_LIB_DEFECTS
	// 151. can't currently clear() empty container
	__glibcxx_check_erase_range(__first, __last);
	typename _Base::iterator __res = _Base::erase(__first.base(),
						      __last.base());
	this->_M_invalidate_all();
	return iterator(__res, this);
      }

#if __cplusplus >= 201103L
      void
      pop_back() // noexcept
      {
	__glibcxx_check_nonempty();
	_Base::pop_back();
	this->_M_invalidate_all();
      }
#endif // C++11

      basic_string&
      replace(size_type __pos1, size_type __n1, const basic_string& __str)
      {
	_Base::replace(__pos1, __n1, __str);
	this->_M_invalidate_all();
	return *this;
      }

      basic_string&
      replace(size_type __pos1, size_type __n1, const basic_string& __str,
	      size_type __pos2, size_type __n2)
      {
	_Base::replace(__pos1, __n1, __str, __pos2, __n2);
	this->_M_invalidate_all();
	return *this;
      }

      basic_string&
      replace(size_type __pos, size_type __n1, const _CharT* __s,
	      size_type __n2)
      {
	__glibcxx_check_string_len(__s, __n2);
	_Base::replace(__pos, __n1, __s, __n2);
	this->_M_invalidate_all();
	return *this;
      }

      basic_string&
      replace(size_type __pos, size_type __n1, const _CharT* __s)
      {
	__glibcxx_check_string(__s);
	_Base::replace(__pos, __n1, __s);
	this->_M_invalidate_all();
	return *this;
      }

      basic_string&
      replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
      {
	_Base::replace(__pos, __n1, __n2, __c);
	this->_M_invalidate_all();
	return *this;
      }

      basic_string&
      replace(__const_iterator __i1, __const_iterator __i2,
	      const basic_string& __str)
      {
	__glibcxx_check_erase_range(__i1, __i2);
	_Base::replace(__i1.base(), __i2.base(), __str);
	this->_M_invalidate_all();
	return *this;
      }

      basic_string&
      replace(__const_iterator __i1, __const_iterator __i2,
	      const _CharT* __s, size_type __n)
      {
	__glibcxx_check_erase_range(__i1, __i2);
	__glibcxx_check_string_len(__s, __n);
	_Base::replace(__i1.base(), __i2.base(), __s, __n);
	this->_M_invalidate_all();
	return *this;
      }

      basic_string&
      replace(__const_iterator __i1, __const_iterator __i2,
	      const _CharT* __s)
      {
	__glibcxx_check_erase_range(__i1, __i2);
	__glibcxx_check_string(__s);
	_Base::replace(__i1.base(), __i2.base(), __s);
	this->_M_invalidate_all();
	return *this;
      }

      basic_string&
      replace(__const_iterator __i1, __const_iterator __i2,
	      size_type __n, _CharT __c)
      {
	__glibcxx_check_erase_range(__i1, __i2);
	_Base::replace(__i1.base(), __i2.base(), __n, __c);
	this->_M_invalidate_all();
	return *this;
      }

      template<typename _InputIterator>
	basic_string&
	replace(__const_iterator __i1, __const_iterator __i2,
		_InputIterator __j1, _InputIterator __j2)
	{
	  __glibcxx_check_erase_range(__i1, __i2);

	  typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist;
	  __glibcxx_check_valid_range2(__j1, __j2, __dist);

	  if (__dist.second >= __dp_sign)
	    _Base::replace(__i1.base(), __i2.base(),
			   __gnu_debug::__unsafe(__j1),
			   __gnu_debug::__unsafe(__j2));
	  else
	    _Base::replace(__i1.base(), __i2.base(), __j1, __j2);

	  this->_M_invalidate_all();
	  return *this;
	}

#if __cplusplus >= 201103L
      basic_string&
      replace(__const_iterator __i1, __const_iterator __i2,
	      std::initializer_list<_CharT> __l)
      {
	__glibcxx_check_erase_range(__i1, __i2);
	_Base::replace(__i1.base(), __i2.base(), __l);
	this->_M_invalidate_all();
	return *this;
      }
#endif // C++11

      size_type
      copy(_CharT* __s, size_type __n, size_type __pos = 0) const
      {
	__glibcxx_check_string_len(__s, __n);
	return _Base::copy(__s, __n, __pos);
      }

      void
      swap(basic_string& __x)
	_GLIBCXX_NOEXCEPT_IF(std::__is_nothrow_swappable<_Base>::value)
      {
	_Safe::_M_swap(__x);
	_Base::swap(__x);
      }

      // 21.3.6 string operations:
      const _CharT*
      c_str() const _GLIBCXX_NOEXCEPT
      {
	const _CharT* __res = _Base::c_str();
	this->_M_invalidate_all();
	return __res;
      }

      const _CharT*
      data() const _GLIBCXX_NOEXCEPT
      {
	const _CharT* __res = _Base::data();
	this->_M_invalidate_all();
	return __res;
      }

      using _Base::get_allocator;

      size_type
      find(const basic_string& __str, size_type __pos = 0) const
	_GLIBCXX_NOEXCEPT
      { return _Base::find(__str, __pos); }

      size_type
      find(const _CharT* __s, size_type __pos, size_type __n) const
      {
	__glibcxx_check_string(__s);
	return _Base::find(__s, __pos, __n);
      }

      size_type
      find(const _CharT* __s, size_type __pos = 0) const
      {
	__glibcxx_check_string(__s);
	return _Base::find(__s, __pos);
      }

      size_type
      find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
      { return _Base::find(__c, __pos); }

      size_type
      rfind(const basic_string& __str, size_type __pos = _Base::npos) const
	_GLIBCXX_NOEXCEPT
      { return _Base::rfind(__str, __pos); }

      size_type
      rfind(const _CharT* __s, size_type __pos, size_type __n) const
      {
	__glibcxx_check_string_len(__s, __n);
	return _Base::rfind(__s, __pos, __n);
      }

      size_type
      rfind(const _CharT* __s, size_type __pos = _Base::npos) const
      {
	__glibcxx_check_string(__s);
	return _Base::rfind(__s, __pos);
      }

      size_type
      rfind(_CharT __c, size_type __pos = _Base::npos) const _GLIBCXX_NOEXCEPT
      { return _Base::rfind(__c, __pos); }

      size_type
      find_first_of(const basic_string& __str, size_type __pos = 0) const
	_GLIBCXX_NOEXCEPT
      { return _Base::find_first_of(__str, __pos); }

      size_type
      find_first_of(const _CharT* __s, size_type __pos, size_type __n) const
      {
	__glibcxx_check_string(__s);
	return _Base::find_first_of(__s, __pos, __n);
      }

      size_type
      find_first_of(const _CharT* __s, size_type __pos = 0) const
      {
	__glibcxx_check_string(__s);
	return _Base::find_first_of(__s, __pos);
      }

      size_type
      find_first_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
      { return _Base::find_first_of(__c, __pos); }

      size_type
      find_last_of(const basic_string& __str,
		   size_type __pos = _Base::npos) const _GLIBCXX_NOEXCEPT
      { return _Base::find_last_of(__str, __pos); }

      size_type
      find_last_of(const _CharT* __s, size_type __pos, size_type __n) const
      {
	__glibcxx_check_string(__s);
	return _Base::find_last_of(__s, __pos, __n);
      }

      size_type
      find_last_of(const _CharT* __s, size_type __pos = _Base::npos) const
      {
	__glibcxx_check_string(__s);
	return _Base::find_last_of(__s, __pos);
      }

      size_type
      find_last_of(_CharT __c, size_type __pos = _Base::npos) const
	_GLIBCXX_NOEXCEPT
      { return _Base::find_last_of(__c, __pos); }

      size_type
      find_first_not_of(const basic_string& __str, size_type __pos = 0) const
	_GLIBCXX_NOEXCEPT
      { return _Base::find_first_not_of(__str, __pos); }

      size_type
      find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const
      {
	__glibcxx_check_string_len(__s, __n);
	return _Base::find_first_not_of(__s, __pos, __n);
      }

      size_type
      find_first_not_of(const _CharT* __s, size_type __pos = 0) const
      {
	__glibcxx_check_string(__s);
	return _Base::find_first_not_of(__s, __pos);
      }

      size_type
      find_first_not_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
      { return _Base::find_first_not_of(__c, __pos); }

      size_type
      find_last_not_of(const basic_string& __str,
		       size_type __pos = _Base::npos) const
	_GLIBCXX_NOEXCEPT
      { return _Base::find_last_not_of(__str, __pos); }

      size_type
      find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const
      {
	__glibcxx_check_string(__s);
	return _Base::find_last_not_of(__s, __pos, __n);
      }

      size_type
      find_last_not_of(const _CharT* __s, size_type __pos = _Base::npos) const
      {
	__glibcxx_check_string(__s);
	return _Base::find_last_not_of(__s, __pos);
      }

      size_type
      find_last_not_of(_CharT __c, size_type __pos = _Base::npos) const
	_GLIBCXX_NOEXCEPT
      { return _Base::find_last_not_of(__c, __pos); }

      basic_string
      substr(size_type __pos = 0, size_type __n = _Base::npos) const
      { return basic_string(_Base::substr(__pos, __n)); }

      int
      compare(const basic_string& __str) const
      { return _Base::compare(__str); }

      int
      compare(size_type __pos1, size_type __n1,
	      const basic_string& __str) const
      { return _Base::compare(__pos1, __n1, __str); }

      int
      compare(size_type __pos1, size_type __n1, const basic_string& __str,
	      size_type __pos2, size_type __n2) const
      { return _Base::compare(__pos1, __n1, __str, __pos2, __n2); }

      int
      compare(const _CharT* __s) const
      {
	__glibcxx_check_string(__s);
	return _Base::compare(__s);
      }

      //  _GLIBCXX_RESOLVE_LIB_DEFECTS
      //  5. string::compare specification questionable
      int
      compare(size_type __pos1, size_type __n1, const _CharT* __s) const
      {
	__glibcxx_check_string(__s);
	return _Base::compare(__pos1, __n1, __s);
      }

      //  _GLIBCXX_RESOLVE_LIB_DEFECTS
      //  5. string::compare specification questionable
      int
      compare(size_type __pos1, size_type __n1,const _CharT* __s,
	      size_type __n2) const
      {
	__glibcxx_check_string_len(__s, __n2);
	return _Base::compare(__pos1, __n1, __s, __n2);
      }

      _Base&
      _M_base() _GLIBCXX_NOEXCEPT		{ return *this; }

      const _Base&
      _M_base() const _GLIBCXX_NOEXCEPT	{ return *this; }

      using _Safe::_M_invalidate_all;
    };

  template<typename _CharT, typename _Traits, typename _Allocator>
    inline basic_string<_CharT,_Traits,_Allocator>
    operator+(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
	      const basic_string<_CharT,_Traits,_Allocator>& __rhs)
    { return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs; }

  template<typename _CharT, typename _Traits, typename _Allocator>
    inline basic_string<_CharT,_Traits,_Allocator>
    operator+(const _CharT* __lhs,
	      const basic_string<_CharT,_Traits,_Allocator>& __rhs)
    {
      __glibcxx_check_string(__lhs);
      return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs;
    }

  template<typename _CharT, typename _Traits, typename _Allocator>
    inline basic_string<_CharT,_Traits,_Allocator>
    operator+(_CharT __lhs,
	      const basic_string<_CharT,_Traits,_Allocator>& __rhs)
    { return basic_string<_CharT,_Traits,_Allocator>(1, __lhs) += __rhs; }

  template<typename _CharT, typename _Traits, typename _Allocator>
    inline basic_string<_CharT,_Traits,_Allocator>
    operator+(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
	      const _CharT* __rhs)
    {
      __glibcxx_check_string(__rhs);
      return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs;
    }

  template<typename _CharT, typename _Traits, typename _Allocator>
    inline basic_string<_CharT,_Traits,_Allocator>
    operator+(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
	      _CharT __rhs)
    { return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs; }

  template<typename _CharT, typename _Traits, typename _Allocator>
    inline bool
    operator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
	       const basic_string<_CharT,_Traits,_Allocator>& __rhs)
    { return __lhs._M_base() == __rhs._M_base(); }

  template<typename _CharT, typename _Traits, typename _Allocator>
    inline bool
    operator==(const _CharT* __lhs,
	       const basic_string<_CharT,_Traits,_Allocator>& __rhs)
    {
      __glibcxx_check_string(__lhs);
      return __lhs == __rhs._M_base();
    }

  template<typename _CharT, typename _Traits, typename _Allocator>
    inline bool
    operator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
	       const _CharT* __rhs)
    {
      __glibcxx_check_string(__rhs);
      return __lhs._M_base() == __rhs;
    }

  template<typename _CharT, typename _Traits, typename _Allocator>
    inline bool
    operator!=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
	       const basic_string<_CharT,_Traits,_Allocator>& __rhs)
    { return __lhs._M_base() != __rhs._M_base(); }

  template<typename _CharT, typename _Traits, typename _Allocator>
    inline bool
    operator!=(const _CharT* __lhs,
	       const basic_string<_CharT,_Traits,_Allocator>& __rhs)
    {
      __glibcxx_check_string(__lhs);
      return __lhs != __rhs._M_base();
    }

  template<typename _CharT, typename _Traits, typename _Allocator>
    inline bool
    operator!=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
	       const _CharT* __rhs)
    {
      __glibcxx_check_string(__rhs);
      return __lhs._M_base() != __rhs;
    }

  template<typename _CharT, typename _Traits, typename _Allocator>
    inline bool
    operator<(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
	      const basic_string<_CharT,_Traits,_Allocator>& __rhs)
    { return __lhs._M_base() < __rhs._M_base(); }

  template<typename _CharT, typename _Traits, typename _Allocator>
    inline bool
    operator<(const _CharT* __lhs,
	      const basic_string<_CharT,_Traits,_Allocator>& __rhs)
    {
      __glibcxx_check_string(__lhs);
      return __lhs < __rhs._M_base();
    }

  template<typename _CharT, typename _Traits, typename _Allocator>
    inline bool
    operator<(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
	      const _CharT* __rhs)
    {
      __glibcxx_check_string(__rhs);
      return __lhs._M_base() < __rhs;
    }

  template<typename _CharT, typename _Traits, typename _Allocator>
    inline bool
    operator<=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
	       const basic_string<_CharT,_Traits,_Allocator>& __rhs)
    { return __lhs._M_base() <= __rhs._M_base(); }

  template<typename _CharT, typename _Traits, typename _Allocator>
    inline bool
    operator<=(const _CharT* __lhs,
	       const basic_string<_CharT,_Traits,_Allocator>& __rhs)
    {
      __glibcxx_check_string(__lhs);
      return __lhs <= __rhs._M_base();
    }

  template<typename _CharT, typename _Traits, typename _Allocator>
    inline bool
    operator<=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
	       const _CharT* __rhs)
    {
      __glibcxx_check_string(__rhs);
      return __lhs._M_base() <= __rhs;
    }

  template<typename _CharT, typename _Traits, typename _Allocator>
    inline bool
    operator>=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
	       const basic_string<_CharT,_Traits,_Allocator>& __rhs)
    { return __lhs._M_base() >= __rhs._M_base(); }

  template<typename _CharT, typename _Traits, typename _Allocator>
    inline bool
    operator>=(const _CharT* __lhs,
	       const basic_string<_CharT,_Traits,_Allocator>& __rhs)
    {
      __glibcxx_check_string(__lhs);
      return __lhs >= __rhs._M_base();
    }

  template<typename _CharT, typename _Traits, typename _Allocator>
    inline bool
    operator>=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
	       const _CharT* __rhs)
    {
      __glibcxx_check_string(__rhs);
      return __lhs._M_base() >= __rhs;
    }

  template<typename _CharT, typename _Traits, typename _Allocator>
    inline bool
    operator>(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
	      const basic_string<_CharT,_Traits,_Allocator>& __rhs)
    { return __lhs._M_base() > __rhs._M_base(); }

  template<typename _CharT, typename _Traits, typename _Allocator>
    inline bool
    operator>(const _CharT* __lhs,
	      const basic_string<_CharT,_Traits,_Allocator>& __rhs)
    {
      __glibcxx_check_string(__lhs);
      return __lhs > __rhs._M_base();
    }

  template<typename _CharT, typename _Traits, typename _Allocator>
    inline bool
    operator>(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
	      const _CharT* __rhs)
    {
      __glibcxx_check_string(__rhs);
      return __lhs._M_base() > __rhs;
    }

  // 21.3.7.8:
  template<typename _CharT, typename _Traits, typename _Allocator>
    inline void
    swap(basic_string<_CharT,_Traits,_Allocator>& __lhs,
	 basic_string<_CharT,_Traits,_Allocator>& __rhs)
    { __lhs.swap(__rhs); }

  template<typename _CharT, typename _Traits, typename _Allocator>
    std::basic_ostream<_CharT, _Traits>&
    operator<<(std::basic_ostream<_CharT, _Traits>& __os,
	       const basic_string<_CharT, _Traits, _Allocator>& __str)
    { return __os << __str._M_base(); }

  template<typename _CharT, typename _Traits, typename _Allocator>
    std::basic_istream<_CharT,_Traits>&
    operator>>(std::basic_istream<_CharT,_Traits>& __is,
	       basic_string<_CharT,_Traits,_Allocator>& __str)
    {
      std::basic_istream<_CharT,_Traits>& __res = __is >> __str._M_base();
      __str._M_invalidate_all();
      return __res;
    }

  template<typename _CharT, typename _Traits, typename _Allocator>
    std::basic_istream<_CharT,_Traits>&
    getline(std::basic_istream<_CharT,_Traits>& __is,
	    basic_string<_CharT,_Traits,_Allocator>& __str, _CharT __delim)
    {
      std::basic_istream<_CharT,_Traits>& __res = getline(__is,
							  __str._M_base(),
							__delim);
      __str._M_invalidate_all();
      return __res;
    }

  template<typename _CharT, typename _Traits, typename _Allocator>
    std::basic_istream<_CharT,_Traits>&
    getline(std::basic_istream<_CharT,_Traits>& __is,
	    basic_string<_CharT,_Traits,_Allocator>& __str)
    {
      std::basic_istream<_CharT,_Traits>& __res = getline(__is,
							  __str._M_base());
      __str._M_invalidate_all();
      return __res;
    }

  typedef basic_string<char>    string;

#ifdef _GLIBCXX_USE_WCHAR_T
  typedef basic_string<wchar_t> wstring;
#endif

  template<typename _CharT, typename _Traits, typename _Allocator>
    struct _Insert_range_from_self_is_safe<
      __gnu_debug::basic_string<_CharT, _Traits, _Allocator> >
      { enum { __value = 1 }; };

} // namespace __gnu_debug

#endif