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.

15 lines
416 B
C++

#pragma once
#include "links/BaseLink.h"
#include <stdexcept>
template <class TElem>
class OneToOneLink : public BaseLink<TElem> {
public:
OneToOneLink(std::shared_ptr<TElem> e) : BaseLink<TElem>(e) {}
void addChild(const std::shared_ptr<TElem>& child) override {
if (!this->children_.empty())
throw std::logic_error("OneToOneLink cannot have more than one child");
BaseLink<TElem>::addChild(child);
}
};