#include <string>
#include <iostream>

struct Foo {
	char c;
	void set(std::string s) {c = s[0];}; // We don't really care here
};
struct Bar {
	int n;
	void set(std::string s) {n = s.size();}; // We don't really care here
};

template<typename T>
struct Identified {
    T model;
    std::string id;
};

template<typename T>
Identified<T> GetIdentifiedModel(std::string id) {
    Identified<T> result;
    result.id = id;
    // Obviously shouldn't be ID but for the example
    result.model.set(id);  // Common method for T
    return result;
}

void assert(bool b) {
	if (b) std::cout << "OK" << std::endl;
	else std::cout << "There is a problem !" << std::endl;
};

int main() {
	auto fooWithID = GetIdentifiedModel<Foo>("foo id");
	auto barWithID = GetIdentifiedModel<Bar>("bar");
	assert (fooWithID.model.c == 'f');
	assert (barWithID.model.n == 3);
	return (0);
}