brintos

brintos / llvm-project-archived public Read only

0
0
Text · 460 B · dc9c01b Raw
27 lines · cpp
1#include <memory>2 3struct NodeS;4 5// Class to wrap pointers.6class wrap_ptr {7public:8  NodeS *ptr;9 10  wrap_ptr(NodeS *n_ptr) : ptr(n_ptr) {}11};12 13struct NodeS {14  wrap_ptr next;15  int value;16 17  NodeS(NodeS *n_ptr, int val) : next(wrap_ptr(n_ptr)), value(val) {}18};19 20int main(int argc, char **argv) {21 22  // Make a short linked list of fake smart pointers.23  auto ptr_node = wrap_ptr(new NodeS(new NodeS(nullptr, 2), 1));24 25  return 0; // Set a breakpoint here26}27