FAQ Database Discussion Community


Boost unit test link error — abi mismatch?

c++,unit-testing,boost,linker,abi
I'm trying to build a unit test with boost, but the linker complains about a missing function. Take this skeleton code #define BOOST_TEST_DYN_LINK #define BOOST_TEST_MAIN #include <boost/test/unit_test.hpp> BOOST_AUTO_TEST_SUITE(TestFuncOps); BOOST_AUTO_TEST_CASE(CopyConstructor) { } BOOST_AUTO_TEST_SUITE_END(); But it fails with Undefined symbols for architecture x86_64: "boost::unit_test::ut_detail::normalize_test_case_name[abi:cxx11](boost::unit_test::basic_cstring<char const>)", referenced from:...

How can I create empty array node using boost property_tree of json parser

c++,arrays,json,boost
I'm trying to create an array node in json, which output is like this: { node: ["12", "13"] } but when array is empty, it will output this: { node: "" } that's not what I want, I need this: { node: [] } How can I do that ?...

C++: digits vs bits?

c++,boost,standards,bit,digits
I am trying to understand the difference of vocabulary used in the C++ language between digits and bits as in : CHAR_BIT; std::numeric_limits<char>::digits; Is there a conceptual difference? Maybe for weird architectures? If so, what would be called the result of the operator[] of std::bitset. Does it give access to...

How should boost::lockfree::spsc_queue's read_available and write_available be used?

c++,boost,lock-free
Boost documentation for spsc_queue says: read_available(): Thread-safe and wait-free, should only be called from the producer thread write_available(): Thread-safe and wait-free, should only be called from the consumer thread I would expect the most common use case to be just the other way around: producer thread (thread writing data to...

C++ boost::regex_match strange behaviour

c++,c++11,boost,boost-regex
Trying boost::regex_match and got a strange behaviour. boost::cmatch what; std::string fn_re_str = R"(\.sig\|\|([a-zA-Z0-9$]+)\()"; boost::regex fn_re(fn_re_str); if (boost::regex_match("{var d=a[c];if(d.sig||d.s){var e=d.sig||qt(d.", what, fn_re)) { std::cout << what[1] << std::endl; } else { std::cerr << "not found" << std::endl; } qt is expected to be found. Here https://regex101.com/r/iR9rW5/1 it is found. Why boost::regex_match...

Issue with boost::program_options and positional parameters

c++,boost
gcc 4.7.2 / boost 1.58.0 I am trying code that looks like this, taken almost exclusively from the example in the documentation: namespace po = boost::program_options; po::options_description desc("Allowed options"); desc.add_options() ("help","produce help message") ; po::positional_options_description pos_desc; pos_desc.add("input-file",-1); po::variables_map vm; // The following line throws an std::logic_error // what() - error_with_option_name::m_option_style...

Force Preprocessor Evaluation While Tokenizing

c++,boost,metaprogramming
Is there a way to force the preprocessor to completely evaluate the symbols before tokenizing? An example of the input and output I want GFR_SER_##token, GFR_SER_INT. As an example, I'm trying to do some pre-processor meta-programming using Boost::PP. For pasting strings, it's fairly easy as you just add a level...

C++ Pointer being freed was not allocated (possibly, an issue with unique_ptr or boost::ublas)

c++,boost,memory-leaks,unique-ptr,ublas
This is a follow up on one of my previous questions. The issue that I am dealing with is explained in detail in the formulation of this question. Unfortunately, I was not able to provide a minimal example that showcases the problem. In this question, I am making an attempt...

What is the purpose of boost mpi request's m_handler

c++,asynchronous,boost,request,mpi
I am trying to test an mpi request if it is done or not. However, there is a problem that I could not figure out. If I use test_all method as below, then I see that request is not done. string msg; boost::mpi::request req = world->irecv(some_rank, 0, msg); vector<boost::mpi::request> waitingRequests;...

std::bind and boost::bind tricks

c++11,boost
#include <functional> #include <boost/bind.hpp> class A { public: A(){} ~A(){} template<typename _Handler> void call_handler(_Handler handler) { handler(); } }; class B { public: template<typename _Handler> void call_handler(_Handler handler) { } template<typename _Handler> void run(_Handler handler) { m_a.call_handler(boost::bind(&B::call_handler<_Handler>, this, handler)); //only can use boost::bind here } A m_a; }; class Test...

How to get rid of the “.\r\n” characters appended to the error message from FormatMessageA?

c++,windows,boost,stl
I'm replacing boost::system::error_code with std::errc. The error_code supports displaying the error message in string format through error_code::message(). But I think in STL, we don't have a pre-defined way to do it. Am I right? If I'm wrong, please tell me the default way of doing it without writing my own...

boost graph library: deterministic order of iteration of in_edges?

c++,boost,boost-graph
TL;DR: I would very much like for the order of iteration of in_edges on my graph (adjacency_list with edge_list of setS) to be determinstic, but as far as I can tell, the order of iteration is determined by a comparison operator that is just pointer comparison---thus iteration order is determined...

How do I convert boost::spirit::qi::lexeme's attribute to std::string?

c++,boost,boost-spirit,boost-spirit-qi,boost-phoenix
Consider: struct s { AttrType f(const std::string &); }; ...and a rule r with an attribute AttrType: template <typename Signature> using rule_t = boost::spirit::qi::rule<Iterator, Signature, boost::spirit::qi::standard::space_type>; rule_t<AttrType()> r; r = lexeme[alnum >> +(alnum | char_('.') | char_('_'))][ _val = boost::phoenix::bind(&s::f, s_inst, _1) ]; When compiling this (with clang), I get...

Polymorphic setter for Boost::variant

c++,templates,boost
I am trying to use the boost::variant with template types. For example, I have a template type Tag<T> and the boost::variant AnyTag comprises types such as Tag<double>, Tag<int> and Tag<std::string>. Each Tag<T> has members of type T. Now, I would like to put those variants in a container and simply...

dispatch response packet according to packet sequence id

c++,boost,boost-asio
I have a third-part server, and I'm writing a dll interface for it, my clients use my dll to communicate with the server. The protocol uses a long tcp connection, all traffic goes from this tcp connection. There could be sending/receiving multiple packets at the same time, like a send_msg...

Clean way to make portable endian-correct file-reading / writing code in C++

c++,boost,endianness
I want to write some C++ code that can read and write from files in an endian-correct way. More exactly, I want to be able to read a particular type of file, whose endianness I can easily detect (its magic number being reversed or not). But how would I then...

OSX “clang++ -lboost_mpi”` ->“ld: library not found for -lboost_mpi” after brew install boost --with-mpi

c++,osx,boost,brew,boost-mpi
After installing boost with mpi support using brew I still get the error ld: "library not found for -lboost_mpi" when I run clang++ -lboost_mpi. What can I do to overcome this? I installed boost using brew: $ brew install boost --with-mpi --without-single ==> Downloading https://downloads.sourceforge.net/project/boost/boost/1.58.0/boost_1_58_0.tar.bz2 Already downloaded: /Library/Caches/Homebrew/boost-1.58.0.tar.bz2 ==> ./bootstrap.sh...

write_graphviz does not work when vertex list is setS?

c++,boost,graph
The following code has errors: cannot bind ‘std::basic_ostream’ lvalue to ‘std::basic_ostream&& #include <boost/graph/graphviz.hpp> void foo(int,char*[]) { using namespace boost; typedef boost::adjacency_list< boost::setS, // outedge list boost::setS, // vertex list boost::directedS, // undirected boost::no_property, // vertex prop boost::no_property, // edge prop boost::no_property, // graph prop boost::setS // edgelistc > Graph; Graph...

How to create boost subgraph with setS vertices list?

c++,boost,graph
The following code has errors: AAA.cpp:23:15: required from here .../boost/include/boost/graph/subgraph.hpp:333:5: error: static assertion failed: (!is_same<edge_index_type, boost::detail::error_property_not_found>::value) AAA.cpp:27:21: error: no matching function for call to ‘add_vertex(foo(int, char**)::<anonymous enum>, Graph&)’ AAA.cpp:27:21: note: candidates are: .../boost/include/boost/graph/subgraph.hpp: In instantiation of...

Using Boost adaptors with std::bind expressions

c++,c++11,boost,boost-range
I have the following code: #include <boost/range/adaptor/transformed.hpp> #include <boost/range/algorithm.hpp> #include <iostream> #include <functional> #include <memory> struct A { A() = default; A(const A&) = delete; A& operator=(const A&) = delete; }; struct B { B() = default; B(const B&) = delete; B& operator=(const B&) = delete; int foo(const A&, int...

will the shared_ptr be deleted if i delete the class

c++,boost,shared-ptr
I have a class like this : Header: class CurlAsio { public: boost::shared_ptr<boost::asio::io_service> io_ptr; boost::shared_ptr<curl::multi> multi_ptr; CurlAsio(); virtual ~CurlAsio(); void deleteSelf(); void someEvent(); }; Cpp: CurlAsio::CurlAsio(int i) { id = boost::lexical_cast<std::string>(i); io_ptr = boost::shared_ptr<boost::asio::io_service>(new boost::asio::io_service()); multi_ptr = boost::shared_ptr<curl::multi>(new curl::multi(*io_ptr)); } CurlAsio::~CurlAsio() { } void CurlAsio::someEvent() {...

Boost.MultiArray arbitrary start and end index

c++,boost
I have a class that looks like this. The purpose is to have an arbitrary starting and ending point, but operator [] maps to index 0 for the lower bound. template <class T> class Vec : public std::vector<T> { public: Vec() { this->reserve(32000); } Vec(std::string s, int upperbound, int lowerbound)...

Does BOOST asio supports eventfd? like epoll

c++,boost,boost-asio
epoll() can do its poll on lots of fd types such as normal fd, sockets, timefd, eventfd, etc... Can BOOST do it also somehow? I saw in io_service that it supports only: The io_service class provides the core I/O functionality for users of the asynchronous I/O objects, including: boost::asio::ip::tcp::socket boost::asio::ip::tcp::acceptor...

Not able to compile a simple parser written in Boost::Spirit library

c++,boost
following is a minimal size program which I am not able to compile in Boost::spirit library. #include <iostream> #include <string> #include <boost/spirit/include/qi.hpp> #include <boost/lexical_cast.hpp> using namespace boost::spirit; template <typename Iterator> struct z3_exp_grammars : qi::grammar<Iterator, std::string(), ascii::space_type> { z3_exp_grammars() : z3_exp_grammars::base_type(text) { text = qi::int_[qi::_val = boost::lexical_cast<std::string>(qi::_1)]; } qi::rule<Iterator,...

boost spirit: how to match any lexer token in qi?

c++,boost,boost-spirit,boost-spirit-qi,boost-spirit-lex
I would like to match a C++ function declaration with default argument values, but ignoring these values. For example: int myFunction(int a, int b = 5 + 4); Here is (a part of) the lexer: struct Lexer : boost::spirit::lex::lexer<lexer_type> { Lexer() { identifier = "[A-Za-z_][A-Za-z0-9_]*"; numLiteral = "([0-9]+)|(0x[0-9a-fA-F]+)"; this->self.add ("int")...

boost geometry intersection give strage results

c++,boost,boost-geometry
I want to use the intersection function from boost geometry with a line and a polygon. I expect that the intersection is the part of the line which lies inside the polygon. Unfortunately boost geometry returns the part of the line which lies outside of the polygon. Is this a...

Upgraded C++ Project to VS2015, but the Linker is still looking for VC100 Boost library

c++,visual-studio,boost
I have upgraded my C++ project from VS2008 to VS2015. The Platform Toolset is set to Visual Studio 2015 (v140). If it matters, the Target Platform Version is set to 8.1. I built boost using toolset=msvc-14.0 and put the built libraries into the place my project is expecting them. When...

boost::asio::io_service::run does not return while having no work

c++,c++11,boost,boost-asio
From Asio documentation The run() function blocks until all work has finished and there are no more handlers to be dispatched, or until the io_service has been stopped. In the following snippet Asio has no work apart from debug output (which is instantly computed), but run() does not return. #define...

Boost filesystem iteration fails with a long path

c++,boost,visual-studio-2013,boost-filesystem
I'm trying to iterate into a folder using boost::filesystem, but when the path is too long (absolute path >95 chars), boost fail on iteration. Is some knows boost issue with this? Any idea to solve it? while (itr != boost::filesystem::recursive_directory_iterator()) { ++itr; } I'm using boost 1.57, and VS2013....

Upgrade Compatibility of Boost Serialization with binary archives armv7 to arm64

c++,serialization,boost,boost-serialization,arm64
The company I work for releases on iOS and Android, and now Apple is requiring we update all of our apps to run on the arm64 architecture (previously we only released for armv7). Unfortunately we have been using boost::archive::binary_iarchive's (and binary_oarchive's) to store a lot of user data (saved games,...

boost::spirit::qi difference parser behavior

c++,parsing,boost,boost-spirit,boost-spirit-qi
I'm trying to understand the behavior of Qi's Difference Parsers. With something like this: ruleA = ruleAa | ruleAb | ruleAc ; ruleB = ruleA - ruleAc ; I was imagining that the parser would match ruleB iff the input matches ruleAa or ruleAb. In other words, ruleB would subtract...

Boost error with CGAL SDF algorithm

c++,algorithm,boost,cgal
I'm currently trying to use the SDF algorithm of CGAL but I have some boost errors and I don't know where it's from. I followed the example code from CGAL doc Here's the part of my code : #include <CGAL/Exact_predicates_inexact_constructions_kernel.h> #include <CGAL/boost/graph/graph_traits_Polyhedron_3.h> #include <CGAL/IO/Polyhedron_iostream.h> #include <CGAL/mesh_segmentation.h> #include <CGAL/property_map.h> [...] void...

Can I use the Boost.Range indexed adaptor in a non-const way?

c++,boost
I'm trying to loop through a list, updating each element depending on the value of another list that shares indexes. Ideally, I'd like to do this with a for-range loop like so: std::vector<int> is; std::vector<int> other_list; for (auto &i : is | boost::adaptors::indexed(0)) { i.value() = other_list[i.index()]; } But I...

boost asio TCP server must bind to an IP address?

c++,boost,tcp,boost-asio
I am not sure whether I am using BOOST ASIO properly, my code is as follows, boost::asio::ip::tcp::resolver resolver(io_); boost::asio::ip::tcp::resolver::query query(std::string("127.0.0.1"), port); boost::asio::ip::tcp::endpoint endpoint = *resolver.resolve(query); acceptor_.open(endpoint.protocol()); It binds to 127.0.0.1. When a client is connecting externally, the client is using the IP address 192.168.0.107 or something similar. The server implemented...

C++ Boost::filesystem::path with unicode characters

c++,boost,boost-filesystem
I am new to C++, need a little help here. I have three folders - one in English, one in Japanese and one in Russian for test purposes. When I run this little program #include <windows.h> #include <string> #include <iostream> #include <boost/filesystem.hpp> #include <boost/locale.hpp> using namespace boost::filesystem; using namespace std;...

rcpp codes fails to load with boost library (as implemented in BH) when using boost::iostreams::gzip_decompress

r,boost,rcpp
I wish to read data from a .bz file. I am trying to do it using rcpp plus boost using the BH library. I am running R 3.2.0 on MacOSX 10.10.3, Rcpp version 0.11.6, and BH 1.58.0-1. Here is my code thus far: // [[Rcpp::depends(BH)]] #include <Rcpp.h> #include <iostream> #include...

a pointer to a shared object is different in different objects which owns it

c++,boost,boost-thread
I have a problem with sharing a pointer to a shared object. I have one object of type C in class A, which is sharing a pointer to it with a object of type B. Then the object has a thread which is changing the value val of object c...

making shared_ptr's from Boost.Spirit.Qi

c++,parsing,boost,shared-ptr,boost-spirit-qi
I would like to use a Spirit Qi grammar to parse text into shared pointers to strings. Actually, I would like to parse multivariate polynomials into a system of them, with various kinds of previously-encountered symbols appearing in the polynomials, but for now, let's parse from text into std::shared_ptr<std::string>. I...

Calling C++ class methods via a function pointer using boost::function

c++,boost
I want to use pointers to a class method using boost, I saw this answer in stackoverflow that has an example of using boost: Calling C++ class methods via a function pointer However when I am trying to add a more complicated function,I don't know how to call it using...

Boost template error using inter-process map

c++,templates,boost,variadic-templates,interprocess
EDIT: Although not strictly the the answer I was looking for, that is because I was asking the wrong question. I have marked this question as "answered" because it helped me see what I was doing wrong (when put back in context, the class structure doesn't make sense and needs...

Correct getters for non intrusive boost serialization C++

c++,serialization,boost,boost-serialization
I would like to provide getters of class A for my non-member serialize() function` since accessing from members is private. template<typename T> class A { public: A(const T& id) : m_id(id) {} T& getRef() { return m_id; } // not giving good results T getId() { return m_id; } //...

Finding number between [/ and ] using regex in C++

c++,regex,boost
I want to find the number between [/ and ] (12345 in this case). I have written such code: float num; string line = "A111[/12345]"; boost::regex e ("[/([0-9]{5})]"); boost::smatch match; if (boost::regex_search(line, match, e)) { std::string s1(match[1].first, match[1].second); num = boost::lexical_cast<float>(s1); //convert to float cout << num << endl; }...

Which library does boost::type belong to?

c++,boost
I was trying to solve a problem with boost::mpl::for_each, when I came across this question. The answer mentions a type named boost::type. It works well if I include <boost/type.hpp>. My question is, which Boost library it belongs to? Is it documented anywhere? While it really is just a dumb empty...

Compiling Boost asio on cygwin occurs many errors

c++,boost
I train official Boost asio example(timer.cpp) on cygwin. And I want to compile it without creating any .lib or .dll and minimize dependencies for distributing by open-source. But when I copy only asio and config directories and asio.hpp and config.hpp files into libs directory(According the official manual, Boost asio requires...

Calculating execution time using boost::chrono

c++,boost,type-conversion,global-variables
I tried to calculate the sum of a function execution time in a loop but something goes wrong : #include <boost/chrono.hpp> #include <iostream> boost::chrono::milliseconds sumGlobal; int main() { boost::chrono::high_resolution_clock::time_point t1 ; boost::chrono::high_resolution_clock::time_point t2 ; for (i=0;i<10;i++) { t1 = boost::chrono::high_resolution_clock::now(); f(); //to waste time t2 = boost::chrono::high_resolution_clock::now(); sumGlobal +=...

Boost library missing at runtime (Can compile. Can't run)

c++,boost,shared-libraries
This is a pretty entry level question but I just can't seem to find any relevant answers. I can compile this no problem using the following command: g++ client.cpp -o client -lboost_system -lpthread When I try to run the program I get the following error: ./client ./client: error while loading...

c++ read in image set with different file names without hardcoding

c++,image,opencv,boost,image-loading
Is there any way of reading in a set of images from file that all have varying names to each other, i.e. no continuity at all? So if you had 4 images in the same folder with the file names of: head.jpg shoulders.png knees.tiff toes.bmp Without hard coding the file...

C++ Syntax: return statement with space after “template”; what does it mean [duplicate]

c++,boost,c++14,boost-interprocess
This question already has an answer here: Where and why do I have to put the “template” and “typename” keywords? 6 answers TL;DR: What does the following Syntax for the functions return type and the return statement mean? (Code from boost::interprocess) template <class T> typename segment_manager::template construct_proxy<T>::type construct(char_ptr_holder_t name)...

Convert boost::container::boost basic_string to std::string

c++,boost,stdstring,boost-interprocess
Is there a simple way to do this? I've tried the following: typedef allocator<char,managed_shared_memory::segment_manager> CharAllocator; typedef boost::container::basic_string<char, std::char_traits<char>, CharAllocator> my_basic_string; std::string s(my_basic_string); ...

C++ Compile error on NetBSD '::system' has not been declared

c++,unix,boost,g++,netbsd
I have some C++ code that compiles nicely on Linux but so far I'm having trouble getting it to compile correctly on NetBSD. These are my includes: #include <fstream> #include <iostream> #include <cstdlib> #include <unistd.h> #include <iomanip> #include <boost/regex.hpp> I compile with this command: g++ -v -O2 -fno-strict-aliasing -I /usr/pkg/include...

parsing into std::vector with Spirit Qi, getting segfaults or assert failures

c++,parsing,boost,boost-spirit,boost-spirit-qi
I am using Spirit Qi as my parser, to parse mathematical expressions into an expression tree. I keep track of such things as the types of the symbols which are encountered as I parse, and which must be declared in the text I am parsing. Namely, I am parsing Bertini...

cgi won't work with boost regex

c++,regex,c++11,boost,cgi
I am attempting to write a cgi program (using cgicc) which incorporates the boost regex library. The program works perfectly with std regex, but I am trying to change to boost regex to test the performance difference. The program also works perfectly if I create an offline version that does...

boost shared pointer constructor destructor

c++,boost,shared-ptr
The following code struct Base { public: Base() { std::cout<<"Base Ctr"; } ~Base() { std::cout<<"Base Dtr"; } }; struct Derived : Base { Derived() { std::cout<<"Derived Ctr"; } ~Base() { std::cout<<"Derived Dtr"; } }; int main() { Base* b = new Derived; delete b; } gives me the following output...

brew link boost to homebrew python

python,boost,homebrew,boost-python,brew
After installing boost with brew using the system layout option --layout=system (set using brew edit boost155) brew install boost155 --with-python --with-mpi --without-single I discovered that my boost library talks to the osx python, not the homebrew version $ otool -L `brew list boost155 | grep python.dylib` | grep -i python...

boost mpi sends NULL messages

c++,string,boost,mpi
I am trying to send some MPI messages to a process using boost library. However, the receiver side cannot receive them properly. The receiver gets only NULL, instead of the real messages. My code is here: // Receiver side, rank = 0 boost::mpi::communicator* world // initialization of the world, etc......

Create OpenSSL certificates signed by myself

c++,ssl,boost,openssl,ssl-certificate
I'm using boost ssl for server and client, and I have a model for server/client program in my mind, and I'm not sure it's gonna work. The model I have in my mind is to be the only authority for certificates of my program. My main question is: How can...

Make Boost Matrix attribute of a class

c++,boost
I want to make a Boost Matrix as an attribute of my class Adsorbate. I know beforehand that it will be (3,2). I want to do: #include <boost/numeric/ublas/matrix.hpp> using namespace boost::numeric::ublas; class Adsorbate { matrix<double> m(3,2); }; so that the compiler knows the size of the attribute m and thus...

compile error when using boost::lockfree::spsc_queue (Is it a bug in boost?)

c++,visual-studio,boost
I defined a variable as follow: boost::lockfree::spsc_queue<std::vector<char *>, boost::lockfree::capacity<10> > myVariable; and in my code, I tried to rest it : myVariable.reset(); but when I am compiling my code I am getting this error: Error 17 error C2660: 'boost::lockfree::detail::ringbuffer_base<T>::pop' : function does not take 1 arguments C:\Local\boost\boost\lockfree\spsc_queue.hpp Why I am...

(C/C++) Unknown compiler version while compiling Boost with MSVC 14.0 (VS 2015)

c++,c,boost,visual-studio-2015
I get "Unknown compiler version - please run configure tests and report the results" while attempting to compile Boost library on my computer. I have most recent Boost (as of date of the post) - 1.58.0. Doesn't Boost support MSVC 14.0, yet? How do I "run the configure tests"? Screenshots.

Compile and use boost for Android NDK R10e

android,c++,boost,android-ndk
How do I compile and use Boost for the Android NDK? I've tried everything I've found online, from Boost for Android to compiling it myself with the bjam file. However, I do not succeed. When I try compiling it with bjam, I get the following error: error: toolset gcc initialization:...

Using boost multiprecision with trigonometric function

c++,boost,multiprecision
Consider the following code which creates a multiprecision floating-point number 'a' by using boost. How do I use boost library to invoke trigonometric functions? For example, I hope to calculate sin(a). #include <iostream> #include "boost/multiprecision/cpp_bin_float.hpp" using namespace std; using namespace boost::multiprecision; typedef number<backends::cpp_bin_float<24, backends::digit_base_2, void, boost::int16_t, -126, 127>, et_off> float32;...

CSV like Parse ( whitespace delimiter and boost )

c++,boost
i want to parse a CSV-like file, line with boost. There are many different methods like split, tokenise, spirit, regex... A parsing line could look like: "abc" "def" "hij \"hgfd\" " and the result should look like: "abc" "def" "hij \"hgfd\" " I thought that using boost's tokenises with the...

How to generate normal random numbers using boost multiprecision?

c++,boost,random,normal-distribution
I'm trying to generate random numbers from normal distribution using boost's multiprecision. I can generate random numbers from uniform distributions, but when I tried to generate from standard normal, it reports an error. Here is the code: (follows from Examples from boost, change mpz_int to cpp_int, and mpf_float_50 to cpp_dec_float_50)...

How does Boost.Units come up with this imprecise result of conversion?

c++,boost,boost-units
Consider the following code: #include <boost/units/io.hpp> #include <boost/units/systems/si/plane_angle.hpp> #include <boost/units/systems/angle/degrees.hpp> #include <iostream> #include <cmath> #include <limits> int main() { using namespace boost::units; std::cout.precision(std::numeric_limits<double>::digits10); std::cout << "Everyone knows that 180 deg = " << std::acos(-1.) << " rad\n"; std::cout << "Boost thinks that 180 deg = " <<...

Missing boosts filesystem lib after build

c++,boost
I have the latest version of boost (1.58). After building it via command line on windows: bootstrap .\b2 I add boost dir to path and boost/stage/lib to lib path. I add #include to my code and when I compile I get an error saying: Error 1 error LNK1104: cannot open...

How return leaf nodes of a boost::property_tree

c++,boost,boost-propertytree
I have a property tree where all the data is stored in its leaf nodes. The Tree, however, has a complex structure. What I want to do now is: get all (and only the) leaf nodes of the tree, for they contain the data and recall the path leading to...

How to rename node/element in boost property tree?

c++,boost,boost-propertytree
For example I have boost property tree of following structure (created by reading stream with xml or in different way): <A> <B> <C></C> </B> </A> How to rename in existing tree element B to new element with new key: N. So invoking write_xml of this fixed tree should give new...

boost python template argument deduction/substitution failed when exporting function

python,c++,boost,boost-python
I'm trying to export two overloaded functions to Python. So I first define the pointers to these functions and then I use them to expose the functions to Python. BOOST_PYTHON_MODULE(mylib){ // First define pointers to overloaded function double (*expt_pseudopot02_v1)(double,double,double,const VECTOR&, int,int,int,double,const VECTOR&, int,int,int,double,const VECTOR& ) = &pseudopot02; boost::python::list (*expt_pseudopot02_v2)(double, double,...

Boost Bind to Method

c++,boost,boost-thread,boost-bind
I'm trying to use boost thread to multi-thread one of my applications. The part I have an issue with is the boost::bind. Here is what I am trying to do : boost::bind(&Class::CalculateRT(i, i - 1), RT)); Considering : RT is a TransformType typedef std::pair<Eigen::Matrix3d, Eigen::Vector3d> TransformType; And CalculateRT is a...

Create an optional tuple

c++,boost,tuples,variadic-templates,optional
I don't understand why there is no optional tuple, and I mean by that, something like this ; optional<int,string,char> that would combine an optional int, optional string and optional char. You can think of it like an optimized std::tuple<boost::optional<T>...> where the booleans used by the optionals would be all together...

Motivation to use boost::phoenix::val?

c++,boost,boost-phoenix
Please, could you show situations, where the use of boost::phoenix::val is indispensable (or at least very handy), not just optional. Boost doc doesn't go far beyond examples like std::cout<<boost::phoenix::val(3)(); //output is 3. When and why one would prefer boost::phoenix::val(t)(); instead of just t; ...

Is there a flat unsorted map/set implementation?

c++,c++11,boost,stl,containers
There is the boost.container flat_map and others, and the Loki AssocVector and many others like these which keep the elements sorted. Is there a modern (c++11 move-enabled, etc.) implementation of an unsorted vector adapted as a map/set? The idea is to use it for very small maps/sets (less than 20...

Getter for dynamic array in c++ not working

c++,boost,multidimensional-array
I am using a dynamic array from boost in one of my classes and having trouble to write a proper getter function for it. Heres what I tried (I checked the size of the array within the class setter and with the getter from the main function): #include <iostream> #include...

Can't find certain Boost library function

c#,c++,boost,tree,nearest-neighbor
I am trying to implement a k-d tree in C# and the source I'm looking at is in C++ with Boost. The function I'm trying to find is util::subtract(). I've searched all through Boost's documentation and I can't find it anywhere. Line number 94 is the function I'm trying to...

Boost serialization does not work between 32bit and 64bit machine. Any other serialization / compression library?

c++,serialization,boost,32bit-64bit,cereal
I am trying to use the boost library to serialize on 64bit machine and de-serialize on 32bit machine. However, it seems it does not work. (I use 1.57.0). If I run the following code boost::asio::streambuf buf; std::ostream os(&buf); boost::archive::binary_oarchive oa(os); printf("Buffer size %d\n",(int)buf.size()); The output of 32bit machine is 37...

Tagged boost::bimap in templates - do they work?

templates,c++11,boost,tags,bimap
I am embedding a boost::bimap in a templated class, and after much trial-and-error I have discovered something that compiles and something that does not. I am using g++ (GCC) 4.9.2 20150212 (Red Hat 4.9.2-6) and Boost 1.55. I will give the full code in Example 1 and only the changed...

Using custom seekable source boost::iostreams::stream

c++,boost
What methods are required to be implemented if I want to use a custom seekable source with boost::iostreams::stream? I've looked at Boost's tutorial for source buffers that aren't seekable, and tried modifying the tag to input_seekable and adding a seek function as in this tutorial. Unfortunately, this causes my compiler...

Cannot link Boost to CMake-based project on VS2015 RC

c++,visual-studio,visual-c++,boost,cmake
It gives the error: LINK : fatal error LNK1104: cannot open file 'boost_unit_test_framework-vc140-mt-gd-1_58.lib' [C:\projects\boost-http\build\algorithm.vcxproj] You can see the full error at AppVeyor. The build script (CMakeLists.txt and how cmake is invoked) can be found on the project repository. I've tried a lot, but nothing seems to help. Documentation doesn't help...

Dynamic loose source routing in IP networks

c++,visual-studio-2012,boost,routing,ip
Okay guys, I have this idea to recreate a program wich could find the best rout in IP networks. I found one guy on the internet who did it, and he shared some code..but whatever I'm doing with it, I can't make it work. I'm using Visual Studio 2012 with...

Boost.Python converter for pointers doesn't work

python,c++,pointers,boost
TLDR: Is it possible to pass C++ pointer types through python converters? Here I declared my MyStruct and pointer type for it PMYSTRUCT, converter template class PointerConverter and that python module: #include <boost/python.hpp> namespace py = boost::python; template<class T, class Converter> void from_python_converter() { py::converter::registry::push_back(&Converter::convertable, &Converter::construct, py::type_id<T>()); } template<typename POINTER_TYPE>...

Error while using Boost Asio

c++,boost,mingw,boost-asio,codeblocks
I get "::UnregisterWaitEx is not declared" inside win_object_handle_service.ipp whenever I try to include < boost/asio.hpp > into my code. Currently I am using Code::Blocks, MinGW compiler (which didn't come bundled with IDE) on Windows 8.1. Boost is built outside of mingw include folder, though is included in project settings. Exact...

Get an ordered list of files in a folder

c++,boost,boost-filesystem
I have used boost::filesystem::directory_iterator in order to get a list of all the available files into a given folder. The problem is that I supposed this method would give me the files in alphabetical order, while the results seem pretty random. Is there any fancy way of alphabetically sorting them?...

combine boost unordered_map, bind, and std::find_if

c++,boost
I have a big container of boost::unordered_map like below: typedef boost::unordered_map< vertex, entity > vertex_container; The vertex class has a coordinate member variable representing its location. I have several coordinate point_(s). I would like search if any vertex inside my container exist so that vertex.coordinate = point. something like: vertex_container::iterator...

Parsing a boost::variant with User Defined Datatype containing std::string using Spirit Qi

c++,boost,boost-spirit-qi
I'm trying to create a GPIB parser using Spirit.Qi. Sometimes the response can be either an error or a normal response. This seemed like a good use case for the alternative parser which yields a boost::variant; however, if one of the variant types contains a string the code fails to...

error C4996: 'std::_Copy_impl': is it safe to disable it? [duplicate]

c++,visual-studio-2012,boost,odeint
This question already has an answer here: xutility(2227): warning C4996: 'std::_Copy_impl' 1 answer I'm using odeint boost for solving differential equations. In visual studio 2010, there is no errors showing up but when I use visual studio 2013, I get this error xutility(2132): error C4996: 'std::_Copy_impl': Function call with...

C++ Boost Regex doesn't save capture

c++,regex,boost
I am trying to communicate with a web page,retrieve it's source code and than search and store specific strings( names ) inside an output file. Here is what I did: #include <iostream> #include <string> #include <conio.h> #include <boost/asio.hpp> #include <boost/regex.hpp> #include <fstream> using namespace std; ofstream o("out.txt"); int main() {...

Non-intruisive Boost serialization of labelled enums C++

c++,serialization,boost
I would like to serialize struct A where I could save the tag name of the enum expressions instead of its integer in a non intruisive way (without having to change struct A). enum e_fruit { apple, banana, coconut }; struct A { e_fruit fruit; int num; }; namespace boost...

boost spirit: how to instruct the parser to read whole input and then report the result

c++,boost
I have a minimal example of an expression grammar (arithmetic expressions only) which should succeed only when the complete input is a valid arithmetic expression. It seems to me that parser is reporting success when even a subsequence results into the start symbol of the parser. template <typename Iterator> struct...

Creation of a functor inside a member function without taking the class as a argument

c++,boost,bind,functor
Apologies for the cryptic decryption. I wish to create a functor of the following type: const boost::function<bool ()>& functor Please consider the class: #include <boost/function.hpp> class X { public: bool foo(); void bar() ; }; void X::bar() { const boost::function<bool (X *)>& f = &X::foo; } bool X::foo() { std::cout...

When should I use a upgradable lock?

multithreading,boost,synchronization
I have used sharable lock and exclusive lock, but I don't have the opportunity to use upgradable lock. If there is a need to upgrade from sharable lock to exclusive lock, just unlock the sharable lock and get the exclusive lock. So under what situation should I use the upgradable...

Exception thrown when locking boost::unique_lock which is already locked in other thread

c++,multithreading,boost
There is global object boost::unique_lock. One thread locks it. When other thread tries to lock the exception "already owns the mutex" thrown. Why this is happening? I expect the thread to be blocked until other thread will call unlock. boost::mutex mutex; boost::unique_lock<boost::mutex> lock(mutex); static void* scheduller(void* arg) { boost::this_thread::sleep(boost::posix_time::seconds(5)); lock.lock();...

Parse html escape sequence with boost spirit

c++,parsing,boost,boost-spirit
I try to parse text with html escape sequences and want to chnage this esaceps with they utf8 equvivalents: &nbsp; - 0xC2A0 utf8 representation &shy; - 0xC2AD utf8 representation And have gramar to solve this template <typename Iterator> struct HTMLEscape_grammar : qi::grammar<Iterator, std::string()> { HTMLEscape_grammar() : HTMLEscape_grammar::base_type(text) { htmlescapes.add("&nbsp;", 0xC2AD);...

boost/lexical_cast.hpp not found

c++,visual-studio,boost
In a different project which I unfortunately deleted, I was able to use Boost. I added the libaries in the project configuration, and then I declared #include <boost/lexical_cast.hpp> Everything was fine. Now in my new project I am getting the error boost/lexical_cast.hpp not found I have followed the instruction on...

Same weights for different boost graphs

c++,boost,boost-graph
I have just realized that I have not yet understood how to use boost graph library. I have this code: #include <iostream> #include <boost/graph/adjacency_list.hpp> using namespace std; using namespace boost; typedef unsigned int WeightType; typedef adjacency_list<listS, vecS, bidirectionalS, no_property, property<edge_weight_t, WeightType>> Graph; typedef graph_traits<Graph>::vertex_descriptor Vertex; typedef graph_traits<Graph>::edge_descriptor Edge; typedef property_map<Graph,...

How to traverse an graph branch, from specific node with Boost.Graph?

c++,boost,graph
Will be grateful for help . I have tree structure and want print nodes in order of occurrence, with respect of hierarchy . For example I wan traverse all child of N1: [N0, N1[N2, N3, N4[N5], N6] And I'm expect to get N1 N2 N3 N4 N5 But I'm receive...

Forward declaration of type defined with `using`

c++,boost,forward-declaration
Let's assume I have such situation: //A.hpp #include "B.hpp" #include "C.hpp" #include "D.hpp" using A = boost::variant<B, C, D>; //B.hpp #include <memory> class A; using AA = std::unique_ptr<A>; This give me following error: error: typedef redefinition with different types ('boost::variant<B, C, D>' vs 'A') I can't omit #include's in A.hpp...

How to convert a homogeneous fusion::vector to an (std/boost)::array

c++,boost,boost-fusion
I am relatively new to boost, so I believe this is an easy problem: Given, say a fusion::vector<int, int, int>, I need a good way to turn it into an array<int, 3>.

Search a boost MPL sequence for a type with a boost placeholder

c++,boost,template-meta-programming
I have a boost mpl vector with different types and want to know if one specific type is in that vector. But that type contains a template parameter that is a boost placeholder (which I want to replace afterwards) Code: #define BOOST_MPL_LIMIT_VECTOR_SIZE 20 #define BOOST_MPL_LIMIT_MAP_SIZE 20 #include <boost/typeof/std/utility.hpp> #include <boost/mpl/placeholders.hpp>...

What does boost::asio::spawn do?

c++,boost,boost-asio,boost-coroutine
I am unable to form a mental picture of how the control flow happens with spawn. When I call spawn(io_service, my_coroutine), does it add a new handler to the io_service queue that wraps a call to the my_coroutine? When inside the coroutine I call an async function passing it my...

MPL replace without casting the fusion container

c++,boost,c++14,fusion,mpl
I have this class struct MyChildrenNeedsSpace : HaveChildren<MyChildrenNeedsSpace> { typedef childrenListType<string, string, string, string> context; const context children; MyChildrenNeedsSpace() : children("this", "sentence", "needs", "spaces") { std::cout << endl << "The children type is:" << endl << typeid(children).name() << endl; } }; it uses CRTP to allow the HaveChildren class to...