[Solved] Extracting class from demangled symbol

This is hard to do with perl’s extended regular expressions, which are considerably more powerful than anything in C++. I suggest a different tack: First get rid of the things that don’t look like functions such as data (look for the D designator). Stuff like virtual thunk to this, virtual table for that, etc., will … Read more

[Solved] how to convert char * to boost::shared_ptr?

You cannot convert a string literal to a shared pointer. Let me just “correct” your code, and then all you have remaining is undefined behavior: const char *str = “abcdfg”; boost::shared_ptr<char> ss(str); Now, this will compile, but it will produce serious problems because str is not memory that was allocated dynamically. As soon as the … Read more

[Solved] What datatype would is expected for the arrays in c++?

I’m guessing here based on the many questions leading up to this. It is pretty obvious that you do not want sample type to be a scalar, but a 2-dimensional array. I will sketch a generic short-cut that would allow you to write mean_square_displacement::operator() to accept those, potentially even without knowing the concrete type(s) of … Read more

[Solved] Using boost to generate random numbers between 1 and 9999 [closed]

Did you try googling for “boost random number” first? Here’s the relevant part of their documentation generating boost random numbers in a range You want something like this: #include <time.h> #include <boost/random/mersenne_twister.hpp> #include <boost/random/uniform_int_distribution.hpp> std::time(0) gen; int random_number(start, end) { boost::random::uniform_int_distribution<> dist(start, end); return dist(gen); } edit: this related question probably will answer most of … Read more

[Solved] What variations of vector-like containers already widely established? Do I have to write my own? [closed]

Here are the ones I know of: Traditional a.k.a. plain a.k.a. C array vector unique_ptr with an array-type template argument array valarray dynarray static_vector (see also here) small_vector stable_vector There are also “variable-length arrays” and “arrays with runtime bounds”, which do not exist in C++; the former exists in C. See also this question and … Read more

[Solved] How to pass the values stored in vector container to a new variable?

double position_array = first_cells(); This tries to invoke first_cells (a vector) as a callable (but it doesn’t implement operator(): https://en.cppreference.com/w/cpp/container/vector). Assuming that the loop variable is there for a reason, why not use it: double position_array = first_cells[i]; Note also this does a possibly unwanted conversion of float to double if you want bounds-checking, use … Read more