转换为模板

时间:2017-05-05 19:04:25

标签: c++

我想知道我该怎么办?将< script type = "text/javascript" > var seriesOptions = [], seriesCounter = 0, names = { { ticker } }; /** * Create the chart when all data is loaded * @returns {undefined} */ function createChart() { Highcharts.stockChart('chart_container', { rangeSelector: { selected: 2 }, yAxis: { labels: { formatter: function() { return (this.value > 0 ? ' + ' : '') + this.value + '%'; } }, plotLines: [{ value: 0, width: 2, color: 'silver' }] }, plotOptions: { series: { compare: 'percent', showInNavigator: true } }, tooltip: { pointFormat: '<span style="color:{series.color}">{series.name}</span>: <b>{point.y}</b> ({point.change}%)<br/>', valueDecimals: 2, split: true }, series: seriesOptions }); } $.each(names, function(i, name) { seriesOptions[i] = { name: name, data: pricerec# from python }; // As we're loading the data asynchronously, we don't know what order it will arrive. So // we keep a counter and create the chart when all the data is loaded. seriesCounter += 1; if (seriesCounter === names.length) { createChart(); } }); < /script> template<typename T>一起使用?

typedef

我正在尝试对模板类型的项目进行排序。

template <typename T>
typedef bool (*cmp_func)(T i0, T i1); // <- syntax error here

1 个答案:

答案 0 :(得分:2)

Typedef不能是模板。但是,C ++ 11 using别名可以是:

template <typename T>
using cmp_func = bool (*)(T i0, T i1);

pre-C ++ 11解决方法是创建一个具有type typedef的模板结构:

template <typename T>
struct cmp_func {
    typedef bool (*type)(T i0, T i1);
};

然后将其引用为typename cmp_func<int>::type