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 -
http://www.boost.org/doc/libs/1_42_0/libs/python/doc/v2/long.html):

namespace python = boost::python;

// compute a factorial without overflowing
python::long_ fact(long n)
{
  if (n == 0)
    return python::long_(1);
  else
     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,
Pavel.

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net