Question

I am intending to use classes that have boost::multiprecision::cpp_int (see Boost Multiprecision) as data members, and I am hoping to manage instances of these classes on the heap using the boost::fast_pool_allocator Boost custom allocator.

In order for this to be safe, I need to know that boost::multiprecision::cpp_int is a POD (or at least that it does no allocation on the heap - i.e., is purely stack-based).

Is boost::multiprecision::cpp_int a POD?

Thanks!

Was it helpful?

Solution 2

The answer, taken from @PlasmaHH's comment, and quite obvious in retrospect, is that no, boost::multiprecision::cpp_int is not a POD.

To quote from PlasmaHH:

Think about it for a moment, where could it possibly extend into when it grows? Also what could maybe "Determines the number of Bits to store directly within the object before resorting to dynamic memory allocation" in the documentation you have linked mean?

OTHER TIPS

Why not write a little program to find out?

#include <iostream>
#include <type_traits>
#include <boost/multiprecision/cpp_int.hpp>

int main()
{
    std::cout << std::is_pod<boost::multiprecision::cpp_int>::value << std::endl;
}

On my platform (gcc version 4.8.2) the output is 0, meaning the type isn't a POD type.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top