blob: 480b18b4a53f5a8fa7c716dba9d2a7d9772e2992 [file]
// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#include <memory>
// Self-reference through a return type.
class Node {
public:
virtual ~Node() = default;
virtual Node* clone() = 0;
};
// Self-reference through a parameter type.
class Merger {
public:
virtual void merge(Merger* other) = 0;
};
// Self-reference through a smart pointer return type.
class Owner {
public:
virtual std::unique_ptr<Owner> take() = 0;
};
// Mutual recursion between two classes.
class Branch;
class Leaf {
public:
virtual Branch* parent() = 0;
};
class Branch {
public:
virtual Leaf* firstLeaf() = 0;
};
Node* node_create(void);
Merger* merger_create(void);
Owner* owner_create(void);
Leaf* leaf_create(void);
Branch* branch_create(void);