template problem

This commit is contained in:
Kevin Darby committed 2019-07-20 00:15:24 -04:00
1 parent 81b7770151
commit 773ea38ffa
5 files changed
+17 -31

No files matched your search

Binary file not shown.
+1 -1
View File
@@ -97,7 +97,7 @@ namespace bts.excel
string funcimpls = string.Join(Environment.NewLine, functions.Select(x => x.function_impl.Replace("__AlgoName__", algoname) ));
cpp = cpp.Replace("__FunctionImpls__", "//__FunctionImpls__" + Environment.NewLine + funcimpls);
string dualdefs = string.Join(Environment.NewLine, functions.SelectMany(x => x.get_dual_definitions().Select( xx => xx ) ).Distinct());
string dualdefs = string.Join(Environment.NewLine, functions.SelectMany(x => x.get_dual_definitions().Select( xx => xx.Replace("__AlgoName__::", "") ) ).Distinct());
cpp = cpp.Replace("__DualDefs__", "//__DualDefs__" + Environment.NewLine + dualdefs);
string dualimpls = string.Join(Environment.NewLine, functions.SelectMany(x => x.get_dual_impls().Select(xx => xx.Replace("__AlgoName__", algoname))).Distinct());
@@ -112,10 +112,10 @@ namespace bts.excel
[ExcelFunction]
[SparkAlgoCode(
// dual_definition = @"
// template <typename T>
// T& sparkalgo_take_snapshot(T&, const std::string& name);",
dual_definition = @"
template <typename T>
T& sparkalgo_take_snapshot(T&, const std::string& name);",
dual_impl = @"
template<typename T>
T& __AlgoName__::sparkalgo_take_snapshot(T& rng, const std::string& name)
{
-5
View File
@@ -198,11 +198,6 @@ struct Range
return end;
}
};
template struct Range<double>;
template struct Range<string>;
template struct Range<int32_t>;
template struct Range<uint32_t>;
class __AlgoName__ : public IAlgoOrder
{
+13 -22
View File
@@ -198,12 +198,6 @@ struct Range
return end;
}
};
template struct Range<float>;
template struct Range<double>;
template struct Range<string>;
template struct Range<int32_t>;
template struct Range<uint32_t>;
class algo_example_xlsm : public IAlgoOrder
{
@@ -258,8 +252,19 @@ class algo_example_xlsm : public IAlgoOrder
int sparkalgo_snapshot_switch(const std::string& name, int on_off);
template <typename T>
T& sparkalgo_take_snapshot(T&, const std::string& name);;
template<typename T>
T& sparkalgo_take_snapshot(T& rng, const std::string& name)
{
static std::map< std::string, T > cache;
auto it = cache.find(name);
if(it == cache.end())
{
cache[name] = rng;
return rng;
}
else
return it->second;
};
};
SecurityKey algo_example_xlsm::sparkalgo_resolve_security_id(const string& contract, const string& symbol,
@@ -425,20 +430,6 @@ int algo_example_xlsm::sparkalgo_snapshot_switch(const std::string& name, int on
return sparkalgo_take_snapshot(on_off,name+"_switch");
}
template<typename T>
T& algo_example_xlsm::sparkalgo_take_snapshot(T& rng, const std::string& name)
{
static std::map< std::string, T > cache;
auto it = cache.find(name);
if(it == cache.end())
{
cache[name] = rng;
return rng;
}
else
return it->second;
}
algo_example_xlsm::algo_example_xlsm() : me(new PImpl()) {}
algo_example_xlsm::~algo_example_xlsm() {}