MCPcopy Create free account
hub / github.com/0voice/cpp_new_features / main

Function main

cpp_11/002_grammar_align.cpp:25–46  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23};
24
25int main()
26{
27 MyAllocator<64> a;
28
29 // allocate a char
30 char* p1 = a.aligned_alloc<char>();
31 if (p1)
32 *p1 = 'a';
33 std::cout << "allocated a char at " << (void*)p1 << '\n';
34
35 // allocate an int
36 int* p2 = a.aligned_alloc<int>();
37 if (p2)
38 *p2 = 1;
39 std::cout << "allocated an int at " << (void*)p2 << '\n';
40
41 // allocate an int, aligned at 32-byte boundary
42 int* p3 = a.aligned_alloc<int>(32);
43 if (p3)
44 *p3 = 2;
45 std::cout << "allocated an int at " << (void*)p3 << " (32 byte alignment)\n";
46}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected