C++ boost的返回类型::累加器::标记::平均值 请考虑下面的Booost。累加器示例: ValueSype类型< /C> >是一个整数类型: typedef boost::accumulators::features < boost::accumulators::tag::sum , boost::accumulators::tag::min , boost::accumulators::tag::max , boost::accumulators::tag::mean > Features; typedef boost::accumulators::accumulator_set < value_type , Features > Accumulator;

C++ boost的返回类型::累加器::标记::平均值 请考虑下面的Booost。累加器示例: ValueSype类型< /C> >是一个整数类型: typedef boost::accumulators::features < boost::accumulators::tag::sum , boost::accumulators::tag::min , boost::accumulators::tag::max , boost::accumulators::tag::mean > Features; typedef boost::accumulators::accumulator_set < value_type , Features > Accumulator;,c++,boost,types,C++,Boost,Types,我猜类型是双重的。类型是如何推导出来的?我的兴趣被这激发了,所以我在boost源代码中遵循了它 我创建了一个值为\u type=int的累加器。extract \u result的结果实际上是双精度的 这是通过该行在提取结果中推导得出的: typename mpl::apply<AccumulatorSet, Feature>::type::result_type typedef typename numeric::functional::fdiv<Sample, std:

我猜类型是双重的。类型是如何推导出来的?

我的兴趣被这激发了,所以我在boost源代码中遵循了它

我创建了一个值为\u type=int的累加器。extract \u result的结果实际上是双精度的

这是通过该行在提取结果中推导得出的:

typename mpl::apply<AccumulatorSet, Feature>::type::result_type 
typedef typename numeric::functional::fdiv<Sample, std::size_t>::result_type result_type;
typename mpl::apply::type::result\u type
这又取决于这一行:

typename mpl::apply<AccumulatorSet, Feature>::type::result_type 
typedef typename numeric::functional::fdiv<Sample, std::size_t>::result_type result_type;
typedef typename numeric::functional::fdiv::result\u type result\u type;
(其中示例为int)

在这里部分专门用于在分割时将整数强制转换为双倍:

// partial specialization that promotes the arguments to double for
// integral division.
template<typename Left, typename Right>
struct fdiv_base<Left, Right, typename enable_if<are_integral<Left, Right> >::type>
  : functional::divides<double const, double const>
{};
//将参数提升为双精度的部分专门化
//整数除法。
模板
结构fdiv_基础
:功能::划分
{};
示例程序:

#include <iostream>
#include <typeinfo>

#include <boost/accumulators/accumulators.hpp>
#include <boost/accumulators/statistics.hpp>

typedef boost::accumulators::features <
boost::accumulators::tag::sum
, boost::accumulators::tag::min
, boost::accumulators::tag::max
, boost::accumulators::tag::mean
> Features;

typedef boost::accumulators::accumulator_set <
int
, Features
> Accumulator;


using namespace std;



int main()
{
    Accumulator acc;
    acc(0);
    acc(99);


    auto mean = boost::accumulators::extract_result < boost::accumulators::tag::mean > (acc);
    cout << "mean is " << mean << " of type " << typeid(mean).name() << endl;

}
#包括
#包括
#包括
#包括
typedef boost::累加器::功能<
boost::累加器::标记::总和
,boost::累加器::标记::分钟
,boost::累加器::标记::最大
,boost::累加器::标记::平均值
>特征;
类型定义增压::蓄能器::蓄能器组<
int
,特色
>蓄能器;
使用名称空间std;
int main()
{
蓄能器acc;
acc(0);
行政协调会(99);
自动平均值=增压::累加器::提取结果<增压::累加器::标记::平均值>(acc);

我不能遵循
应用
类型定义类型名称数值::函数::fdiv::结果类型结果类型;
你能帮我吗?我如坐针毡。@JonathanMee这是什么意思?这意味着他不能坐着不动(在等待我抱歉的解释时,他激动得放错了位置)@这意味着我想阅读刚刚发布的编辑,我害怕他忘记了我。