Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8895949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:54:59+00:00 2026-06-14T23:54:59+00:00

I have a 2D vector and I need to remove blocks that do not

  • 0

I have a 2D vector and I need to remove blocks that do not contain sufficient values:

typedef vector<double> iniMatrix;


bool hasInsufficientEnergy() {
return true;
}
vector<double> Audio::filter(vector<iniMatrix>&blocks, double sumThres, double ZeroThres)
{
  vector<double> totalEnergy;
  vector<double> totalZeroCross;
  double totalSum = sumThres * blocks.size();
  double totalZero = ZeroThres * blocks.size();

  vector<iniMatrix> blockked;

  for(unsigned i=0; (i < blocks.size()); i++)
  {
    totalEnergy.push_back(abs(this->energy(blocks[i])));
    totalZeroCross.push_back(zerocross(blocks[i]));

    if(!totalEnergy[i] > totalSum || totalZeroCross[i] < ZeroThres)
    {
        hasInsufficientEnergy();
    }else{
        //hasInsufficientEnergy();
    }
    iniMatrix::iterator erase_after = remove_if(blocks[i].begin(), blocks[i].end(),
                                                &hasInsufficientEnergy);
 }
 }

The problem is erase_after and comes up with an error message:

In function ‘_OutputIterator std::remove_copy_if(_InputIterator, _InputIterator, 
 _OutputIterator, _Predicate) [with _InputIterator = __gnu_cxx::__normal_iterator<double*, 
std::vector<double, std::allocator<double> > >, _OutputIterator = 
__gnu_cxx::__normal_iterator<double*, std::vector<double, std::allocator<double> > >, 
_Predicate = bool]’:
/usr/include/c++/4.2.1/bits/stl_algo.h:1302:   instantiated from ‘_ForwardIterator 
std::remove_if(_ForwardIterator, _ForwardIterator, _Predicate) [with _ForwardIterator = 
__gnu_cxx::__normal_iterator<double*, std::vector<double, std::allocator<double> > >, 
_Predicate = bool]’
Audio.cpp:105:   instantiated from here
/usr/include/c++/4.2.1/bits/stl_algo.h:1227: error: ‘__pred’ cannot be used as a function

Anyone have any ideas to where I am going wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T23:55:01+00:00Added an answer on June 14, 2026 at 11:55 pm

    true or false aren’t function objects. If you want to use remove_if you must give it a pointer to function or function object, which takes a member of the collection as parameter and returns whether to remove it or not. Look at the example in std::remove_if

    AFAICS, you could replace the remove_if/erase into the if and simplify it to:

    for(auto i=blocks.begin(); i != blocks.end(); )
    {
        totalEnergy.push_back(abs(this->energy(*i)));
        totalZeroCross.push_back(zerocross(*i));
    
        if(!totalEnergy.rbegin() > totalSum || totalZeroCross.rbegin() < ZeroThres)
        {
            i = blocks.erase(i);
        } else {
            ++i;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a vector of values I need to add to a second vector
I have a vector declared as a global variable that I need to be
I have a __m256d vector packed with four 64-bit floating-point values. I need to
I have a vector like: a = c(1:10) and I need to remove multiple
I have a vector of pointers to objects. I need to remove an element
I have a 2D vector containing 96 blocks of 600 values, which is what
I have a vector of booleans. I need to set its elements from n-th
I have a vector of pointers to a class. I need to call their
I have a std::vector with the element as pair and need to find all
I have created a vector of sets in my program, and I need to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.