2017-11-28 4 views
1

捨てるようブーストdiscrete_intervalを渡すと:私は次のエラー取得していますこの引数は、次のコードで修飾子[-fpermissive]

#include <gtest/gtest.h> 
#include <algorithm> 
#include <vector> 
#include <boost/icl/interval_set.hpp> 

typedef icl::discrete_interval<unsigned int> Interval; 
typedef icl::interval_set<unsigned int> IntervalSet; 

int main(int argc, char **argv) { 
    // Vector of pairs <epoch, value> 
    std::vector<std::pair<unsigned int, double>> simulatedValues = { 
     std::make_pair<unsigned int, double>(1000, 44.4), 
     std::make_pair<unsigned int, double>(1060, 55.5), 
     std::make_pair<unsigned int, double>(1120, 66.6), 
     std::make_pair<unsigned int, double>(1180, 77.7), 
     std::make_pair<unsigned int, double>(1240, 88.8), 
     std::make_pair<unsigned int, double>(1300, 77.7), 
     std::make_pair<unsigned int, double>(1360, 66.6), 
     std::make_pair<unsigned int, double>(1420, 47.7), 
     std::make_pair<unsigned int, double>(1480, 99.9), 
     std::make_pair<unsigned int, double>(1540, 33.3)}; 
    const double testThreshold = 50.0; 
    IntervalSet alerts; 

    // Create interval set from those epochs where the value is greater than the threshold 
    for(auto timeValPair : simulatedValues) { 
     unsigned int time = timeValPair.first; 
     double value = timeValPair.second; 
     if(value > testThreshold) { 
      alerts += Interval::closed(time, time); 
     } 
    } 

    // Filter out those discrete intervals with less than 5 minutes of duration 
    alerts.erase(
     std::remove_if(alerts.begin(), alerts.end(), [](const auto &x) { return ((x.upper() - x.lower()) < 300); }), 
     alerts.end()); 

    return 0; 
} 

:私の研究から

/usr/include/c++/5/bits/stl_algo.h:868:23: error: passing ‘const boost::icl::discrete_interval<unsigned int>’ as ‘this’ argument discards qualifiers [-fpermissive] 

を、これは一般的であるため、私は述語に非constメソッドを呼んでいますが、これは当てはまりません。上部と下部の両方がconstとして、boost discrete_interval.hppに宣言されています。それで、ここで何が起こっているのですか?

答えて

1

this

template< class ForwardIt, class UnaryPredicate > 
ForwardIt remove_if(ForwardIt first, ForwardIt last, UnaryPredicate p); 

The type of dereferenced ForwardIt must meet the requirements of MoveAssignable.

icl::interval_set<T>::iteratorを参照してくださいはMoveAssignableではありません。

関連する問題