pastebin - collaborative debugging tool
rovema.kpaste.net RSS


C++17 PMR test2
Posted by Anonymous on Wed 3rd Jul 2024 00:56
raw | new post
modification of post by Anonymous (view diff)

  1.  
  2. /*
  3.  * Compile and run with
  4.  * rm -f a.exe* ; clang++ -target x86_64-w64-mingw32 -std=c++17 -Bstatic c++pmr1.cpp
  5.  * $ PATH+=':/usr/x86_64-w64-mingw32/sys-root/mingw/bin/' ./a.exe
  6.  */
  7. #include <array>
  8. #include <cstddef>
  9. #include <iostream>
  10. #include <memory_resource>
  11.  
  12.  
  13. int main(int ac, char *av[])
  14. {
  15.     char buffer[64];
  16.  
  17.     std::pmr::monotonic_buffer_resource pool{buffer, sizeof(buffer)};
  18.     std::pmr::polymorphic_allocator<char> pa{&pool};
  19.     std::pmr::string s{"x", pa};
  20.  
  21.     for (int i=0 ; i < 10 ; i++) {
  22.         s+=s;
  23.     }
  24.  
  25.     std::cout << s << std::endl;
  26.  
  27.     return EXIT_SUCCESS;
  28. }

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at