You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
403 B
C++

#pragma once
#include "links/BaseLink.h"
#include <stdexcept>
template <class TElem>
class OneToOneLink : public BaseLink<TElem> {
public:
using ElemPtr = std::shared_ptr<TElem>;
OneToOneLink(ElemPtr e) : BaseLink<TElem>(e) {}
void addChild(const ElemPtr& child) override {
if (!this->children_.empty())
throw std::logic_error("Too many children");
BaseLink<TElem>::addChild(child);
}
};