samedi 31 décembre 2016

C++ calling superclass with if statment

I think I am missing something here but can't figure out what..

If I do this, I get compile error "error C2446: ':': no conversion from 'const boost::defer_lock_t' to 'const boost::try_to_lock_t'"

public: 
explicit BasicScopedLock( CCondition& condition, bool initiallyLocked = true ) 
    : LockType( condition.mutex, (initiallyLocked == true ? (boost::try_to_lock) : (boost::defer_lock)) ) 
    , m_condition( condition ) 
{ 
} 

But if I do this, it compiles.

public: 
explicit BasicScopedLock( CCondition& condition, bool initiallyLocked = true ) 
    : LockType( condition.mutex, boost::try_to_lock ) 
    , m_condition( condition ) 
{ 
} 

This works too...

public: 
explicit BasicScopedLock( CCondition& condition, bool initiallyLocked = true ) 
    : LockType( condition.mutex, boost::defer_lock ) 
    , m_condition( condition ) 
{ 
} 

Does anyone have a clue on why compiler doesn't like the if statement here?

Thank you!

Aucun commentaire:

Enregistrer un commentaire