pastebin - collaborative debugging tool
rovema.kpaste.net RSS

Difference between
modified post 1cfcc5 by Anonymous on Wed 3rd Jul 2024 00:56
original post 26a740 by Anonymous on Wed 3rd Jul 2024 00:19
Download diff
Show old version | new version | both versions

    
11
22
/*
33
 * Compile and run with
44
 * rm -f a.exe* ; clang++ -target x86_64-w64-mingw32 -std=c++17 -Bstatic c++pmr1.cpp
55
 * $ PATH+=':/usr/x86_64-w64-mingw32/sys-root/mingw/bin/' ./a.exe
66
 */
77
#include <array>
88
#include <cstddef>
99
#include <iostream>
1010
#include <memory_resource>
1111
1212
1313
int main(int ac, char *av[])
1414
{
15-
    constexpr int total_mem{8192};
15+
    char buffer[64];
1616
17-
    std::array<std::byte, total_mem> buf;
17+
    std::pmr::monotonic_buffer_resource pool{buffer, sizeof(buffer)};
18+
    std::pmr::polymorphic_allocator<char> pa{&pool};
1820
19-
    std::pmr::monotonic_buffer_resource pool{buf.data(), buf.size()};
21+
    for (int i=0 ; i < 10 ; i++) {
20-
    std::pmr::string s{"x", &pool};
22+
        s+=s;
23+
    }
2124
25+
    std::cout << s << std::endl;

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