pastebin - collaborative debugging tool
rovema.kpaste.net RSS


C++17 PMR test1
Posted by Anonymous on Wed 3rd Jul 2024 00:19
raw | new post
view followups (newest first): C++17 PMR test2 by Anonymous

  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.     constexpr int total_mem{8192};
  16.  
  17.     std::array<std::byte, total_mem> buf;
  18.  
  19.     std::pmr::monotonic_buffer_resource pool{buf.data(), buf.size()};
  20.     std::pmr::string s{"x", &pool};
  21.  
  22.     for (int i=0 ; i < 8 ; i++) {
  23.         s = s + s;
  24.     }
  25.  
  26.     std::cout << s << std::endl;
  27.  
  28.     return EXIT_SUCCESS;
  29. }

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