Jakob Lund wrote:
> Because there are notes that sit in the Pattern objects. These notes never go
> in the queue. But you're right that there ought to be a 'nicer' way to do
> this, than having to trawl through the code, looking for notes being played...
>
You can temporarily add an extra parameter (say, a bool) to cause
compile errors wherever Note is being created.
You can even use that bool to signal if reference count should be
modified or not (both in constructor and destructor).
> About the priority queue thing:
> Presently, we have
> bool operator>( const Note& a, const Note& b ) { .. compare a with b .. };
> and then use
> std::priority_queue< Note*, std::deque< Note* >, std::greater< Note > >
> The operator itself uses references and won't itself cause object copying.
Looking at libstdc++ headers, it seems that you're right:
template <class _Tp>
struct greater : public binary_function<_Tp, _Tp, bool>
{
bool
operator()(const _Tp& __x, const _Tp& __y) const
{ return __x > __y; }
};
> I suspect (mostly guessing) that what happens is that the compiler, wanting
> to
> use greater<Note> to compare two Note*'s, uses the Note::Note( Note* )
> constructor to create objects, and passes references to those to the operator.
>
That's possible. I'm wondering why the Note::Note (const Note *) has
been used instead of a typical copy constructor (perhaps to reduce the
chance of unintended consequences of copy constructors?).
> What I tried (in the patch I sent) was to have an operator that compares
> Note*'s directly. Tis seems to make sense; another thing is: Does it work?
>
Looks good to me. Except you don't even need to multiply by m_nTickSize,
unless you expect it to be negative :) (also, make the operator()
inline, it may affect optimization).
Krzysztof
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Hydrogen-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/hydrogen-devel