C++ (Qt)template <typename T>class MyCoolClass {public: MyCoolClass(const T &value) : value_(value) { }private: T value_;};
C++ (Qt)double d = 123.0;MyCoolClass<int> instance(d);
C++ (Qt)template <typename T>struct MyCoolFunctions;
C++ (Qt)template<>struct MyCoolFunctions<float> { static doSomething(float value) { std::cout << value; }};
C++ (Qt)template<>struct MyCoolFunctions<double> { static doSomething(double value) { std::cerr << value; }};
C++ (Qt)template<typename T, typename Traits=MyCoolFunctions<T>>class MyCoolClass {public: MyCoolClass(const T &value) { Traits::doSomething(value); }}
C++ (Qt)double d = 123;float f = 456; MyCoolClass<double> floatInstance (d); // cerrMyCoolClass<float> floatInstance (f); // cout
[Parametr][Name]t[Comment]Время[Type]3[Sorce]0[Parametr][Name]MH[Comment]Наработка[Type]2[Sorce]2[Parametr][Name]R41[Comment]Тв на вх. Д (1)[Dimention]град. Цел.[Type]0[Sorce]0[minPossible]-50[minMarginal]-50[maxMarginal]50[maxPossible]50
QTextStream *in1 = new QTextStream(parametrsFile); while(!in1->atEnd()) { ParametrName temp (*in1); switch (temp.getType()) { case Parametr<float>::continuous: { Parametr<float> tmp(*in1, temp); mainBuffer.append(new Parametr<float>(tmp)); break; } case Parametr<bool>::discreteYesNo: { Parametr<bool> tmp(temp); mainBuffer.append(new Parametr<bool>(tmp)); break; } case Parametr<long>::time: { Parametr<long> tmp(*in1, temp); mainBuffer.append(new Parametr<long>(tmp)); break; } case Parametr<QDateTime>::dateTime: { Parametr<QDateTime> tmp(temp); mainBuffer.append(new Parametr<QDateTime>(tmp)); break; } default: break; } }
C++ (Qt)template <typename T>ParamBase *makeNewParam(const QString &value) {return new Param<T>(value);}
C++ (Qt)static const std::map<QString, std::function<ParamBase*(const QString &)> funMap= { "bool", makeNewParam<bool>, "int", makeNewParam<int>};
C++ (Qt)const QString type("bool");const QString myData("data");myParams += funMap.at(type)(myData);
C++ (Qt)const QString type("bool");const QString myData("data");funMap.at(type)(myData);