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 7195087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:30:28+00:00 2026-05-28T20:30:28+00:00

I did not understand really well how Predicate works, then my question could be

  • 0

I did not understand really well how Predicate works, then my question could be stupid or bad written.

I wrote this class :

namespace Ableton {

    struct DeferencedEqual{

        DeferencedEqual(const Marker* compare_to) : compare_to_(compare_to) { }

        bool operator()(Marker* c1) const {return  *c1 == *compare_to_;}  

        private:
            const Marker* compare_to_;
    };

    struct DeferencedCompare{

        bool operator()(Marker* const* p1, Marker* const* p2){return p1<p2;}

    };


class MarkerContainer {

private:
    std::list<Marker*> list;
    double end_t;
    inline bool exists(std::list<Marker*> *input_list, Marker* check);
   // inline int computeInterval(double to_convert, bool beat_t=true);

public:
    MarkerContainer();
    MarkerContainer(double end_time);
    bool addMarker(Marker* input);
    double computeBeatTime(double sample_t);
    double computeSampleTime(double beat_t);    
    void printAll();
    void sort();

};



}

And this is my .cpp class implementation (just an section in which I am interesting in):

namespace Ableton {

void MarkerContainer::sort(){

   std::sort(list.begin(), list.end(),DeferencedCompare());
}
}

I had got this compiler error:

/usr/include/c++/4.2.1/bits/stl_algo.h:2867:22:{2867:15-2867:21}{2867:24-2867:31}: error: invalid operands to binary expression (‘std::_List_iterator’ and ‘std::_List_iterator’) [2]

Any ideas about ?

Thanks in advance.

Edit One

Hi, I follow your suggests by now I have another problem.

namespace Ableton {

    struct DeferencedEqual{

        DeferencedEqual(const Marker* compare_to) : compare_to_(compare_to) { }

        bool operator()(Marker* c1) const {return  *c1 == *compare_to_;}  

        private:
            const Marker* compare_to_;
    };




    bool compare(Marker* const p1, Marker* const p2){return p1<p2;}










class MarkerContainer {

private:
    std::list<Marker*> list;
    double end_t;
    inline bool exists(std::list<Marker*> *input_list, Marker* check);
   // inline int computeInterval(double to_convert, bool beat_t=true);

public:
    MarkerContainer();
    MarkerContainer(double end_time);
    bool addMarker(Marker* input);
    double computeBeatTime(double sample_t);
    double computeSampleTime(double beat_t);    
    void printAll();
    void sort();

};



}

The function sort is now :

 namespace Ableton {

    void MarkerContainer::sort(){

       list.sort(compare);
    }

    }

And my main.cpp is :

include "Marker.h"
include "MarkerContainer.h"
include <iostream>
include <list>
include <string>
include <cctype>

using namespace std;

int main (int argc, const char * argv[])
{

    Ableton::MarkerContainer::MarkerContainer container =  Ableton::MarkerContainer::MarkerContainer(10.0);
    Ableton::Marker::Marker* one = new Ableton::Marker::Marker(1.0, 1.0);
    Ableton::Marker::Marker* two = new Ableton::Marker::Marker(2.0, 1.0);
    Ableton::Marker::Marker* three = new Ableton::Marker::Marker(3.0, 1.0);

    if(!container.addMarker(one))
        cout << *one << "NOT Added" << endl;
    if(!container.addMarker(two))
        cout << *two << "NOT Added" << endl;
    if(!container.addMarker(three))
        cout << *three << "NOT Added" << endl;
    cout << "-- LIST " << endl;

    container.printAll();

    cout << "-- LIST after sort" << endl;
    //container.printAll();

}

Now I catch this ld error, it sounds strange for me… no way for me in C++ ? 🙂

ld: duplicate symbol Ableton::compare(Ableton::Marker*, Ableton::Marker*) in /…./MarkerContainer.o and /…./main.o for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Command /Developer/usr/bin/clang++ failed with exit code 1

Thanks again in advance, do you can suggest me some book regarding STL and how it works “underground”, in order to understand better what happened in these cases technically speacking

pedr0

  • 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-05-28T20:30:29+00:00Added an answer on May 28, 2026 at 8:30 pm

    Sure: you can’t use std::sort() to sort a std::list<T> because std::sort() requires random access iterators. However, std::list<T> only supports bidrectional iterators. You can use std::list<T>::sort(), however.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There was an interesting question in a practice test that I did not understand
Just could not get this one and googling did not help much either.. First
Im not a high level programmer. I do not understand all this stuff really
I am quite new to the embedded linux programming and did not really understand
I recently inherited an iPhone app. The original developer did not understand memory management
I did search the forum and did not find a similar question. I'm looking
Im really new to Grails and I try to understand how it works. I
Did not have luck with these examples: Javascript File remove Javascript FSO DeleteFile Method
I did not find any suitable questions answered yet, so I'd like to know
I did not make any changes on the code. I dont receive any errors

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.