[C++-sig] boost::python::make_tuple crashing

Simon Pickles sipickles at googlemail.com
Sun Jul 5 18:27:11 CEST 2009


Sorry, had a typo or two:

#include "boost//any.hpp"
#include "boost//python.hpp"
#include <string>
#include <vector>
// RakNet::GetTime for accurate millisecond timimg
#include "GetTime.h"
#include <stdio.h>
#include <iostream>

using namespace std;

void HandleBoostPythonTuple( const boost::python::tuple& b)
{
    const string s = boost::python::extract<std::string>(b[0]);
    const float f = boost::python::extract<float>(b[1]);
    const int ui = boost::python::extract<int>(b[2]);
}

int main()
{
    int count = 0;
    int target = 100000;

    string s = "spam";
    unsigned char i = 42;
    float f = 3.14f;

    cout << "Starting boost.python.tuple test" << endl;
    RakNetTime bptStart = RakNet::GetTime();
    for ( count = 0; count < target; ++count )
    {
        HandleBoostPythonTuple(boost::python::make_tuple(s,f,i));
    }
    RakNetTime bptEnd = RakNet::GetTime();
    cout << "Duration: " << (bptEnd - bptStart) << endl;
    return 0;
}



More information about the Cplusplus-sig mailing list