Mongodb c++ driver issue - c++

I am getting an error saying namespace "bsoncxx::v_noabi::builder::basic" has no member "make_document", I have already added required included as per mentioned in the tutorial.
I am using mongo-cxx-driver-r3.1.1 version.
i have followed example from here
here is what I have tried
#include "maxi.h"
#include <cstdlib>
#include <iostream>
#include <bsoncxx/builder/basic/array.hpp>
#include <bsoncxx/builder/basic/document.hpp>
#include <bsoncxx/builder/basic/kvp.hpp>
#include <mongocxx/client.hpp>
#include <mongocxx/instance.hpp>
using bsoncxx::builder::basic::kvp;
using bsoncxx::builder::basic::make_document;// here is error
using bsoncxx::type;
mongocxx::instance inst{};
mongocxx::client conn{ mongocxx::uri{ "mongodb://localhost:27017" } };
see image here
I have already tested MongoDB driver after compiling and its working perfectly. I need to use make_document option for some reason in order to achieve my goal.
Not sure possible bsoncxx::builder::basic::make_document; option may have been removed or replaced with something else which I don't know.

In the current master branch, document.hpp file contains make_document method.
if I'm not mistaken you are using stable release version.
Take a look here.
Using declaration “not found” in MongoDB c++ driver

Related

Where is '__find_end' present in Visual Studio 19 C/C++ Development Tools?

I was trying to compile an old code, and received the following error:
error G1A4676F8: no member named '__find_end' in namespace 'std'
I searched online and found it is defined in stl_algo.h, which I couldn't find in my Windows system. Also, the documentations were of libstdc++4 and earlier.
The code compiles fine on https://godbolt.org/ with all MSVC versions.
The include statements are:
#include <string>
#include <algorithm>
#include <iterator>
#include <ostream>
#include <iomanip>
#include <stdexcept>
The compiler shows an alternative as find_end defined in algorithm but I am not sure if __find_end has the same functionality as find_end.
So, my question is, is __find_end deprecated?
If not, where can I find it's declaration in Windows?
If yes, what are my alternatives? Is find_end a perfect substitute for __find_end?

Using declaration "not found" in mongodb c++ driver

I'm using the mongo-cxx-driver-r3.1.1 based on mongo-c-driver-1.6.2.
Using the latest examples provided on github, I managed to find how to connect the database and how to save documents.
I'm struggling to fetch results using a filter following the informations provided in the mongocxx/query.cpp example.
There's a lot of call to a make_document method but I have no class/method/template in the bsoncxx namespace with that name (same problem with make_array).
Heres's the includes, the using directives and using declarations :
#include <bsoncxx/builder/basic/document.hpp>
#include <bsoncxx/builder/basic/array.hpp>
#include <bsoncxx/builder/basic/kvp.hpp>
#include <bsoncxx/types.hpp>
#include <bsoncxx/json.hpp>
#include <bsoncxx/stdx/make_unique.hpp>
#include <bsoncxx/stdx/optional.hpp>
#include <bsoncxx/stdx/string_view.hpp>
#include <mongocxx/instance.hpp>
#include <mongocxx/pool.hpp>
#include <mongocxx/stdx.hpp>
#include <mongocxx/client.hpp>
#include <mongocxx/logger.hpp>
#include <mongocxx/uri.hpp>
#include <mongocxx/exception/exception.hpp>
#include <mongocxx/options/find.hpp>
using namespace mongocxx;
using namespace bsoncxx;
using bsoncxx::builder::basic::document;
using bsoncxx::builder::basic::kvp;
using bsoncxx::builder::basic::sub_document;
using bsoncxx::builder::basic::sub_array;
using bsoncxx::builder::basic::array;
using bsoncxx::types::value;
using mongocxx::result::insert_one;
The using declarations "not found" :
using bsoncxx::builder::basic::make_array;
using bsoncxx::builder::basic::make_document;
Am I missing something obvious ?
Are there more recent examples ?
Your code looks right, as you included all necessary header files needed for make_document and make_array.
You said in your comment, that the document.hpp doesn't contain the make_document and the array.hpp doesn't contain the make_array template.
This is right for the release mongo-cxx-driver-r3.1.1.
In the current master branch the header files exists as you can see if you follow the source links for them: document.hpp and array.hpp. The examples you use are probably for the new master branch as they are also from a current branch from git.

C++ Boost and ImageMagick++ API issue

While developing Raspberry Pi library compiled by g++4.9.2 I have met compability issue between boost (1.6.2) and ImageMagick++ API (7.0). When compiling this code:
#include <Magick++.h>
#include <boost/filesystem.hpp>
#include <boost/foreach.hpp>
I got these boost errors:
__assert_fail was not declared in this scope (path_trails.hpp)
...
__assert_fail was not declared in this scope (path.hpp)
...
__assert_fail was not declared in this scope (shared_ptr.hpp)
When deleting #include <Magick++.h> line everything runs fine. Unfortunately I need boost and ImageMagick as well in this source file. How to solve this issue?
A simple workaround is to include Magick++.h after boost.
#include <boost/filesystem.hpp>
#include <boost/foreach.hpp>
#include <Magick++.h>
I don't have a proper explanation for this problem but it seems to come from a clash when using different headers including assert.h (I had the same problem using the assimp library and ImageMagick) but I don't get why the order matters.
Reproducing your case, assert.h is included in:
cassert for boost
MagickCore/pixel-accessor.h for Magick++.h
If someone has an explanation for this problem feel free to edit.

apache Thrift TNonblockingServer Error

I've been following Thrift C++ wiki tutorial. and everything works fine with TSimpleServer.
But, when I try to implement TNonblockingServer I'm getting this error :(
undefined reference to `apache::thrift::server::TNonblockingServer::serve()
undefined reference to `apache::thrift::server::TNonblockingServer::~TNonblockingServer()
I think its something related to the header files or the namespaces.
The following headers im using:
#include <thrift/protocol/TBinaryProtocol.h>
#include <thrift/server/TSimpleServer.h>
#include <thrift/transport/TServerSocket.h>
#include <thrift/transport/TBufferTransports.h>
#include <thrift/concurrency/ThreadManager.h>
#include <thrift/concurrency/PosixThreadFactory.h>
#include <thrift/server/TThreadedServer.h>
#include <thrift/server/TNonblockingServer.h>
using namespace ::apache::thrift;
using namespace ::apache::thrift::protocol;
using namespace ::apache::thrift::transport;
using namespace ::apache::thrift::server;
using namespace ::apache::thrift::concurrency;
any idea whats wrong?
I understand that this is really late reply.
It is due to missing libthriftnb library for TNonblockingServer.
while Tsimplesever and TThreadedServer are in libthrift library so it was works with you.

How to #include hash with ext, tr1, or __gnu_cxx in XCode, C++

I'm trying to work with the google-sparsehash library and I'd like to include the hash library described in the link,
using ext::hash; // or __gnu_cxx::hash, or maybe tr1::hash, depending on your OS
and I've tried one of each:
#include <ext/hash>
#include <ext>
#include <__gnu_cxx>
#include <tr1>
which none worked with XCode. I've also "using", where I was told that __gnu_cxx does not contain "hash". How do I describe this library to XCode (3.2.6) on OS X (10.6.8)?
Or more generally, where is this hash function described in a Mac / XCode?
In C++11:
#include <functional>
using std::hash;
In C++03 with TR1:
#include <tr1/functional>
using std::tr1::hash;
So far as I can tell, it doesn't seem possible to get at the hash functors without also pulling in definitions for the various hash tables. At least not without fooling around with library internal headers.
Try:
#include <ext/hash_map>
using __gnu_cxx::hash;
or:
#include <tr1/unordered_map>
using std::tr1::hash;