Boost logo

Boost Users :

Subject: [Boost-users] boost::python::long_ issue
From: Pavel Grafov (pgrafov_at_[hidden])
Date: 2011-07-26 05:23:08

Hello, guys!

In order to check how does boost::python works with long numbers I
found this snippet of code (found it on the boost documentation page -

namespace python = boost::python;

// compute a factorial without overflowing
python::long_ fact(long n)
  if (n == 0)
    return python::long_(1);
     return n * fact(n - 1); // here points the compiler

However, I cannot compile it - the compiler says "error: conversion
from ‘boost::python::api::object’ to non-scalar type
‘boost::python::long_’ requested", pointing to the line marked. What
am I doing wrong? Supposing multiplying is forbidden, is there another
way to create a boost::python::long greater than the greatest long
(2**32 - 1)?

Best regards,

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at