blob: e091662eae06bce246d2838a10f4802760b605af [file] [log] [blame]
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001//===----------------------------------------------------------------------===//
2//
Howard Hinnantf5256e12010-05-11 21:36:01 +00003// The LLVM Compiler Infrastructure
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004//
Howard Hinnantb64f8b02010-11-16 22:09:02 +00005// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00007//
8//===----------------------------------------------------------------------===//
9
10// <string>
11
12// iterator insert(const_iterator p, initializer_list<charT> il);
13
Howard Hinnant5e571422013-08-23 20:10:18 +000014#if _LIBCPP_DEBUG >= 1
Howard Hinnant499cea12013-08-23 17:37:05 +000015#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
16#endif
17
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000018#include <string>
19#include <cassert>
20
Marshall Clow061d0cc2013-11-26 20:58:02 +000021#include "min_allocator.h"
Howard Hinnant9dcdcde2013-06-28 16:59:19 +000022
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000023int main()
24{
Howard Hinnante3e32912011-08-12 21:56:02 +000025#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000026 {
27 std::string s("123456");
28 std::string::iterator i = s.insert(s.begin() + 3, {'a', 'b', 'c'});
29 assert(i - s.begin() == 3);
30 assert(s == "123abc456");
31 }
Dan Albert1d4a1ed2016-05-25 22:36:09 -070032#if __cplusplus >= 201103L
Howard Hinnant9dcdcde2013-06-28 16:59:19 +000033 {
34 typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
35 S s("123456");
36 S::iterator i = s.insert(s.begin() + 3, {'a', 'b', 'c'});
37 assert(i - s.begin() == 3);
38 assert(s == "123abc456");
39 }
40#endif
Howard Hinnant5e571422013-08-23 20:10:18 +000041#if _LIBCPP_DEBUG >= 1
Howard Hinnant499cea12013-08-23 17:37:05 +000042 {
43 std::string s;
44 std::string s2;
45 s.insert(s2.begin(), {'a', 'b', 'c'});
46 assert(false);
47 }
48#endif
Howard Hinnante3e32912011-08-12 21:56:02 +000049#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000050}