~aritra1911/cylinder

aa46aa51cc66d21b4d144092e7caf84f7a207688 — Aritra Sarkar 3 years ago f50b568
Move implementation of Field into `field_type.tpp'
2 files changed, 14 insertions(+), 3 deletions(-)

M field_type.hpp
A field_type.tpp
M field_type.hpp => field_type.hpp +5 -3
@@ 18,8 18,8 @@ enum FieldType {
 */

struct AbstractField {
    std::string name;
    FieldType type;
    std::string name;

    AbstractField(const FieldType&, const std::string&);
    virtual ~AbstractField() = 0;


@@ 29,9 29,11 @@ template<class T>
struct Field : AbstractField {
    T value;

    Field(const FieldType& type, const std::string& name) : AbstractField(type, name) { }
    Field(const FieldType&, const std::string&);

    Field(const FieldType& type, const std::string& name, const T& value) : AbstractField(type, name), value(value) { }
    Field(const FieldType&, const std::string&, const T&);
};

# include "field_type.tpp"

#endif

A field_type.tpp => field_type.tpp +9 -0
@@ 0,0 1,9 @@
/* Context behind creating this file:
   https://stackoverflow.com/questions/495021/why-can-templates-only-be-implemented-in-the-header-file */

template <class T>
Field<T>::Field(const FieldType& type, const std::string& name) : AbstractField(type, name) { }

template <class T>
Field<T>::Field(const FieldType& type, const std::string& name, const T& value) :
    AbstractField(type, name), value(value) { }