Windows 7 64 SP1 -- MongoDB 2.2.0-rc2 -- Boost 1.42 -- MS VS 2010 Ultimate -- C++ driver
I've written this function:
void printQuery(DBClientConnection &c, std::string &dc, const Query &qu = BSONObj(), std::string sortby = "" )
This fragment:
auto_ptr<DBClientCursor> cursor;
cursor = c.query(dc,qu.sort(sortby))
raises the error:
error C2663: 'mongo::Query::sort' : 2 overloads have no legal conversion for 'this' pointer.
sort (const string &field, int asc=1)
should be the applicable overload. I believe this is something to do with using const Query&
with its member function sort
. But if I change it to Query&
without the const
, then my parameter initialization = BSONObj()
raises:
cannot convert from 'mongo::BSONObj' to 'mongo::Query &'
If I pass by value, then it compiles fine.
Is there a way to avoid either of the errors (beside passing by value)? Thanks!