initializer_list.pass.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. //===----------------------------------------------------------------------===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is dual licensed under the MIT and the University of Illinois Open
  6. // Source Licenses. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. // UNSUPPORTED: c++98, c++03
  10. // <string>
  11. // basic_string(initializer_list<charT> il, const Allocator& a = Allocator());
  12. #include <string>
  13. #include <cassert>
  14. #include "test_allocator.h"
  15. #include "min_allocator.h"
  16. int main()
  17. {
  18. {
  19. std::string s = {'a', 'b', 'c'};
  20. assert(s == "abc");
  21. }
  22. {
  23. std::wstring s;
  24. s = {L'a', L'b', L'c'};
  25. assert(s == L"abc");
  26. }
  27. {
  28. typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
  29. S s = {'a', 'b', 'c'};
  30. assert(s == "abc");
  31. }
  32. {
  33. typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S;
  34. S s;
  35. s = {L'a', L'b', L'c'};
  36. assert(s == L"abc");
  37. }
  38. }