2015-08-16 63 views
0

我目前正在嘗試使用Boost :: accumulators,但在構造函數中初始化時出現編譯錯誤。請查看下面的課程詳情。Boost :: accumulators在Mac OSX上初始化失敗Yosemite

Environment: 
Mac OSX Yosemite 
G++ version: 
4.2.1 
Boot Version: 1.55 

代碼:

class test 
{ 
    public: 
     test(); 
     test(unsigned char windowSize=5): acc(tag::rolling_window::window_size=windowSize){} 
    protected: 
     accumulator_set<unsigned short, stats<tag::rolling_mean > > acc; 
    private: 
}; 

錯誤:

/usr/local/boost/include/boost/accumulators/statistics/rolling_window.hpp|49|error: no viable overloaded operator[] for type 'const boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::accumulators::tag::accumulator, boost::accumulators::accumulator_set<unsigned short, boost::accumulators::stats<boost::accumulators::tag::rolling_mean, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, void> >, boost::parameter::aux::empty_arg_list>'| 

----------- 
/usr/local/boost/include/boost/parameter/aux_/arg_list.hpp|346|note: candidate function not viable: no known conversion from 'keyword<tag::rolling_window_size>' to 'const keyword<key_type>' for 1st argument| 
------------------- 

回答

0

你可能缺乏一些包括,導致不完全類型在初始化ET:

Live On Coliru

#include <boost/accumulators/accumulators.hpp> 
#include <boost/accumulators/statistics.hpp> 
#include <boost/accumulators/statistics/rolling_window.hpp> 
#include <boost/accumulators/statistics/rolling_mean.hpp> 
#include <iostream> 

namespace ba = boost::accumulators; 

class test 
{ 
    public: 
     test(); 
     test(unsigned char windowSize=5): acc(ba::tag::rolling_window::window_size = windowSize){} 
    protected: 
     ba::accumulator_set<unsigned short, ba::stats<ba::tag::rolling_mean > > acc; 
    private: 
}; 

int main() 
{ 
} 
0

感謝您的留言。我已經包含了所有必需的文件,但它看起來像有一個重載的構造函數可能會造成這種情況。我已經刪除了所有的構造函數,並只保留一個初始化列表,並開始工作。再次感謝。

代碼:

#include <boost/accumulators/accumulators.hpp> 
#include <boost/accumulators/statistics.hpp> 
#include <boost/accumulators/statistics/rolling_window.hpp> 
#include <boost/accumulators/statistics/rolling_mean.hpp> 
#include <iostream> 
namespace ba = boost::accumulators; 

class test 
{ 
public: 
    test(unsigned char windowSize=5):   acc(ba::tag::rolling_window::window_size = windowSize){} 
protected: 
    ba::accumulator_set<unsigned short, ba::stats<ba::tag::rolling_mean > > acc; 
private: 
}; 
相關問題