Mangal | 1 Jan 07:00
Picon

Strange issue with Serialization of BiMaps


Hi
I am using Boost 1.40.0 and stlport 5.0 on Visual Studio 2008.
The Bimap deserialization succeeds for 24 elements but starts failing after
that.

Here is the file with all the code

#include "stdafx.h"
#include <boost/archive/binary_oarchive.hpp>
#include <boost/archive/binary_iarchive.hpp>
#include <boost/functional/hash.hpp>
#include <boost/bimap/bimap.hpp>
#include <fstream>
#include <exception>
#include <iostream>

using namespace boost;
using namespace boost::bimaps;

typedef unsigned int uint;

struct GeoNode
{
public:
	GeoNode(){}
	GeoNode(uint x, uint y ): x_geocode(x), y_geocode(y) {}

	friend bool operator==(GeoNode const& a,  GeoNode const& b)
    {
(Continue reading)

TSalm | 1 Jan 17:20
Picon
Favicon

Re: [boost] [program options] Recommended way to specify a list of strings

>>> How would I specify an empty vector of strings as the default value  
>>> for this
>>> option?
>>>
>>> po::value< vector<string> >()->default_value(??)
>>
>> Use vector<string>() as the default value.
>>
> Hi,
>
> I have the same problem.
> But when I'm using :
>
>    configuration.add_options()
>      ("DEFAULT.bytecompile",program_options::value< vector<string>
>> ()->default_value(vector<string>()))
>      ;
>
> G++ won't compile.
>
> Here is the complete source code :
>
>
> #include <vector>
> #include <boost/program_options.hpp>
>
>
> int main(int argc, char** argv)
> {
>    using namespace std;
(Continue reading)

Eric Niebler | 2 Jan 12:30
Picon
Favicon
Gravatar

Re: Defining Statements with Proto

Apologies in advance for only the partial response. I'm pressed for time.

On 1/1/2010 6:29 AM, David A. Greene wrote:
> A few years ago, I asked how to define a grammar with
> Proto to match something like this:
>
> if_(expr) [
>    stmt,
>    stmt,
>   ...
> ].else [
>    stmt,
>    stmt,
>   ...
> ];
<snip>

>
> I didn't understand it then and I don't now.  :)  However, it seems to
> be obsolete since BOOST_PROTO_DEFINE_FUNCTION_TEMPLATE doesn't
> seem to exist anymore (it's not documented, anyway).

It exists, but it's deprecated. It's been replaced with 
BOOST_PROTO_REPEAT and BOOST_PROTO_LOCAL_ITERATE macros. See the docs 
for boost/proto/repeat.hpp.

> So how would this be formulated in modern Boost.Proto?  I'm guessing
> I will need an expression template wrapper (called Expression<>  above) that
> uses some combination of BOOST_PROTO_BASIC_EXTENDS,
> BOOST_PROTO_EXTENDS_SUBSCRIPT and BOOST_PROTO_EXTENDS_FUNCTION.  But of course
(Continue reading)

Pascal Kesseli | 2 Jan 16:08
Picon

[interprocess] Not implemented?

Hi folks

Using boost 1.39.0, I receive the following error message when running my program on the target system:

terminate called after throwing an instance of 'boost::interprocess::interprocess_exception'
  what():  Function not implemented
Aborted

My program uses boost named mutexes. How do I have to interpret this exception?

The target is a MOXA embedded UC-8410 computer, featuring a GCC 4.2 platform.

Thanky for any suggestions and best regards
Pascal


Ski-Weltcup: Alle Rennen, alle Resultate und News auf MSN Sport
_______________________________________________
Boost-users mailing list
Boost-users <at> lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Simon Pickles | 2 Jan 16:42

[UTF] Accessing global fixture members within tests

Hi

I am using the Unit Test Framework to test my use of boost.python. I am 
using a global fixture to initialize the python intepreter a single time 
(rather than before each test).

My problem is I would like to use the Python initialising class in my 
tests, and I can't figure out how to do this. I don't want to use normal 
fixtures since each test would call initialize the interpreter, causing 
problems.

Here is what I want to do:

//////////////////////////////////////////////////////
#include <boost//python.hpp>
#include <boost//test//unit_test.hpp>

#include "..//pythonManager//pythonManager.h"

using namespace boost;

// First make a global fixture which sets up python interpreter
struct PythonManagerFixture
{
    PythonManagerFixture()
    {
        pm.Init();
    }
    PythonManager pm;
};

// Set up suite
BOOST_AUTO_TEST_SUITE(TestPythonManager)

// Only init python interpreter once
BOOST_GLOBAL_FIXTURE(PythonManagerFixture);

BOOST_AUTO_TEST_CASE(TestInit)
{
    // Get python globals dict
    python::dict globalDict = 
python::extract<python::dict>(pm.m_pyGlobals); // COMPILE ERROR 'pm' : 
undeclared identifier
    // Has logging module been imported?
    BOOST_REQUIRE(globalDict.has_key("logging"));
}

BOOST_FIXTURE_TEST_CASE(TestLogCallback, PythonManagerFixture) // 
RUNTIME ERROR pm.Init called a second time - bad
{
    function<void(const string&, const string&)> f = 
pm.GetLogFunction(); // pm is in scope though....
    BOOST_REQUIRE(f);
}

// End the suite
BOOST_AUTO_TEST_SUITE_END()
///////////////////////////////////////////////////////////////////

I need a way to supply the PythonManager instance, pm, to the test cases.

Thanks for any advice

Simon
Horst S | 2 Jan 09:55
Picon

[Accumulators] Evaluation of Expression Tree

Hello!

Given an expression tree over mathematical expressions like 'sum',
'min', 'product', etc. and
a fixed number of variables X1..Xn like the following, would it be
possible to use BOOST Accumulators
to re-evaluate the root evaluation function based on changes in the
values of the variables efficiently?

    sum
      /  \
     /    \
min   product
   /  \   /     /    \
X1   X2  X3  X4

Note that variables appear only as leaf nodes.

Obviously, one can flatten the tree to the following expression:

RootValue = sum( min(X1,X2), product(X2,X3,X4) )

Assuming that the current values of the variables are

X1=3, X2=4, X3=2, X4=2

then RootValue evaluates to 19.
Now setting X2=2 results in 10.

The main objective is to minimize the cost of computing the value of
the root evaluation function
when changing the value of a subset of variables in X1..Xn.
One can assume that the subset of variables that changes each time is
rather small (typically only one)
and the size of the expression tree is rather large.

Are BOOST Accumulators a suitable way to model such kind of expressions and the
corresponding incremental evaluation?

Thanks!
Simon Pickles | 2 Jan 17:14

Re: [UTF] Accessing global fixture members within tests

Simon Pickles wrote:
> Hi
>
> I am using the Unit Test Framework to test my use of boost.python. I 
> am using a global fixture to initialize the python intepreter a single 
> time (rather than before each test).
>
> My problem is I would like to use the Python initialising class in my 
> tests, and I can't figure out how to do this. I don't want to use 
> normal fixtures since each test would call initialize the interpreter, 
> causing problems.
>
> Here is what I want to do:
>
> //////////////////////////////////////////////////////
> #include <boost//python.hpp>
> #include <boost//test//unit_test.hpp>
>
> #include "..//pythonManager//pythonManager.h"
>
> using namespace boost;
>
> // First make a global fixture which sets up python interpreter
> struct PythonManagerFixture
> {
>    PythonManagerFixture()
>    {
>        pm.Init();
>    }
>    PythonManager pm;
> };
>
> // Set up suite
> BOOST_AUTO_TEST_SUITE(TestPythonManager)
>
> // Only init python interpreter once
> BOOST_GLOBAL_FIXTURE(PythonManagerFixture);
>
> BOOST_AUTO_TEST_CASE(TestInit)
> {
>    // Get python globals dict
>    python::dict globalDict = 
> python::extract<python::dict>(pm.m_pyGlobals); // COMPILE ERROR 'pm' : 
> undeclared identifier
>    // Has logging module been imported?
>    BOOST_REQUIRE(globalDict.has_key("logging"));
> }
>
> BOOST_FIXTURE_TEST_CASE(TestLogCallback, PythonManagerFixture) // 
> RUNTIME ERROR pm.Init called a second time - bad
> {
>    function<void(const string&, const string&)> f = 
> pm.GetLogFunction(); // pm is in scope though....
>    BOOST_REQUIRE(f);
> }
>
> // End the suite
> BOOST_AUTO_TEST_SUITE_END()
> ///////////////////////////////////////////////////////////////////
>
> I need a way to supply the PythonManager instance, pm, to the test cases.
>
> Thanks for any advice
>
> Simon
>
Ah, I needed the subtle distinction of a BOOST_FIXTURE_TEST_SUITE, not a 
BOOST_FIXTURE_TEST_CASE
Simon Pickles | 2 Jan 17:18

Re: [UTF] Accessing global fixture members within tests

Simon Pickles wrote:
> Simon Pickles wrote:
>> Hi
>>
>> I am using the Unit Test Framework to test my use of boost.python. I 
>> am using a global fixture to initialize the python intepreter a 
>> single time (rather than before each test).
>>
>> My problem is I would like to use the Python initialising class in my 
>> tests, and I can't figure out how to do this. I don't want to use 
>> normal fixtures since each test would call initialize the 
>> interpreter, causing problems.
>>
>> Here is what I want to do:
>>
>> //////////////////////////////////////////////////////
>> #include <boost//python.hpp>
>> #include <boost//test//unit_test.hpp>
>>
>> #include "..//pythonManager//pythonManager.h"
>>
>> using namespace boost;
>>
>> // First make a global fixture which sets up python interpreter
>> struct PythonManagerFixture
>> {
>>    PythonManagerFixture()
>>    {
>>        pm.Init();
>>    }
>>    PythonManager pm;
>> };
>>
>> // Set up suite
>> BOOST_AUTO_TEST_SUITE(TestPythonManager)
>>
>> // Only init python interpreter once
>> BOOST_GLOBAL_FIXTURE(PythonManagerFixture);
>>
>> BOOST_AUTO_TEST_CASE(TestInit)
>> {
>>    // Get python globals dict
>>    python::dict globalDict = 
>> python::extract<python::dict>(pm.m_pyGlobals); // COMPILE ERROR 'pm' 
>> : undeclared identifier
>>    // Has logging module been imported?
>>    BOOST_REQUIRE(globalDict.has_key("logging"));
>> }
>>
>> BOOST_FIXTURE_TEST_CASE(TestLogCallback, PythonManagerFixture) // 
>> RUNTIME ERROR pm.Init called a second time - bad
>> {
>>    function<void(const string&, const string&)> f = 
>> pm.GetLogFunction(); // pm is in scope though....
>>    BOOST_REQUIRE(f);
>> }
>>
>> // End the suite
>> BOOST_AUTO_TEST_SUITE_END()
>> ///////////////////////////////////////////////////////////////////
>>
>> I need a way to supply the PythonManager instance, pm, to the test 
>> cases.
>>
>> Thanks for any advice
>>
>> Simon
>>
> Ah, I needed the subtle distinction of a BOOST_FIXTURE_TEST_SUITE, not 
> a BOOST_FIXTURE_TEST_CASE
>
Alas, I am mistaken. BOOST_FIXTURE_TEST_SUITE is simply a convenience 
macro, removing the need to add a fixture to each test case.

What I need is a way to perform the fixture setup ONCE, yet allow test 
cases access to the public members
David A. Greene | 2 Jan 18:23

Re: Defining Statements with Proto

On Saturday 02 January 2010 05:30:33 Eric Niebler wrote:

> There is experimental and undocumented support in Proto for members like
> else_. See libs/proto/example/virtual_member.cpp for a working example.

Ah, this is what I was looking for.  What is the "experimental" and 
"undocumented" part?

                                                   -Dave
David A. Greene | 2 Jan 20:40

Re: Defining Statements with Proto

On Saturday 02 January 2010 11:23:19 David A. Greene wrote:
> On Saturday 02 January 2010 05:30:33 Eric Niebler wrote:
> > There is experimental and undocumented support in Proto for members like
> > else_. See libs/proto/example/virtual_member.cpp for a working example.
> 
> Ah, this is what I was looking for.  What is the "experimental" and
> "undocumented" part?

So following this example, I came up with the attached testcase, modified
from the one I posted to the development list.

I know the grammar is not strict enough (it should have a separation between
"expressions" and "statements") but that's not important.

With the modified testcase display_expr breaks with an incomprehensible
compiler error.  I assume I'm missing an operator<< definition somewhere
but I don't know where it belongs.

And I'm still getting the same compiler error on the #if 0'd code.

Thanks for your help!

                                  -Dave
Attachment (proto_test.cc): text/x-c++src, 6114 bytes
_______________________________________________
Boost-users mailing list
Boost-users <at> lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users

Gmane