Manfred Doudar | 1 Jun 2010 03:55
Picon
Picon

Re: [preprocessor] variable repetition


Hello Roman,

Thank you ever so much, and for a lovely solution at that too; far
cleaner than the direction I was heading.  Can't thank you enough!

--Manfred

On Mon, 31 May 2010 17:19:40 +0200
Roman Perepelitsa <roman.perepelitsa <at> gmail.com> wrote:

> 2010/5/31 Manfred Doudar <manfred.doudar <at> rsise.anu.edu.au>
> 
> > Hello,
> >
> > I find I am still far from a solution to this, and hope someone
> > might kindly chime in.  At the _bottom_ of this email is what I've
> > got so far, though falls short of a solution...  help is still
> > sorely needed.
> 
> 
> #include <boost/preprocessor.hpp>
> 
> #define VAR(z, n, k) \
>     bar<BOOST_PP_ENUM_PARAMS(k, T)>(a[n]);
> 
> #define FUN(n) \
>    void foo(BOOST_PP_ENUM_PARAMS(n, T)) \
>    { \
>        BOOST_PP_REPEAT(n, VAR, n) \
(Continue reading)

Sandeep Gupta | 1 Jun 2010 04:30
Picon

Re: BGL property maps



On Mon, May 31, 2010 at 1:09 PM, Arne Schwabe <arne <at> rfc2549.org> wrote:
 Hi,

I trying to wrap my head about the usage of iterator_property_map<RandomAccessIterator, OffsetMap, T, R>

What I am trying to do is the following:


create a map like color with key a graph_node and value type of a struct like


struct foo {
    int numbervists;
    int color;
}

so I can use that in a breadth first like algorithm. The example shows me how to do it for an int but do not know how to change

typedef boost::graph_traits<Graph>::edge_descriptor Edge;

 typedef boost::property_map<Graph, boost::id_tag>::type EdgeID_PMap;
  EdgeID_PMap edge_id = get(boost::edge_index(), G);

  boost::iterator_property_map<int*, EdgeID_PMap, int, int&> capacity_pa(capacity, edge_id),    flow_pa(flow, edge_id);

to use foo instead of int. In my understanding, I would have to change int* to a RandomAccessIterator to to Iterator that has foo as value type. But I am kind of lost how to construct such a thing.

Arne

___

The following code sample should help  you figure it out.

#include <boost/property_map/property_map.hpp>
#include <vector>

struct Foo
{
  int a;
  int b;
};

using namespace boost ;

int main()
{
  int num_nodes = 10;
  std::vector<Foo> foo_store(num_nodes);
  typedef std::vector<Foo>::iterator FooVecIter;
  typedef iterator_property_map<FooVecIter, identity_property_map, Foo, Foo& > Foo_pmap_t;
  Foo_pmap_t  dist_pmap(foo_store.begin(), identity_property_map());


}
 

-Sandeep

_______________________________________________
Boost-users mailing list
Boost-users <at> lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Manfred Doudar | 1 Jun 2010 05:50
Picon
Picon

Re: [preprocessor] add pointer to T..


Thank you Daniel - your suggestion has also now just proved useful.

--Manfred

On Mon, 31 May 2010 00:19:53 +0000
Daniel Bradburn <moagstar <at> hotmail.com> wrote:

> 
> You can also achieve this by using BOOST_PP_ENUM_BINARY_PARAMS and
> BOOST_PP_INTERCEPT to remove the second concatenated index:
> BOOST_PP_ENUM_BINARY_PARAMS(3, T, * BOOST_PP_INTERCEPT) which expands
> to...T0* T0*, T1*
> T0*, T1*, T2*Which will save you having to use the extra define.
> 
> > Date: Mon, 31 May 2010 01:41:20 +1000
> > From: manfred.doudar <at> rsise.anu.edu.au
> > To: boost-users <at> lists.boost.org
> > Subject: Re: [Boost-users] [preprocessor] add pointer to T..
> > 
> > On Sun, 30 May 2010 17:14:47 +0200
> > joel falcou <joel.falcou <at> lri.fr> wrote:
> > 
> > > joel falcou wrote:
> > > > #define MAKE_TYPE(z,n,t) BOOST_PP_CAT(T,n)*
> > > > #define MAKE_ROW(z,n,t) BOOST_PP_ENUM(n,MAKE_TYPE,~)
> > > >
> > > > BOOST_PP_REPEAT(10,MAKE_ROW,~)
> > > 
> > > I missed your need, you may just need to use BOOST_PP_FOR or 
> > > BOOST_PP_ITERATE over your code calling the MAKE_TYPE in
> > > BOOST_PP_ENUM
> > 
> > Hello Joel, turns out you got what I wanted in your first post to
> > me, ..just it's so late in the evening here (quarter to 2 in the
> > morning), that I forgot to put back-slashes on my macros.. (need,
> > more of coffee, and sleep.. well I should do one or the other,
> > can't do one, while I do the other).
> > 
> > Thank you again Joel for bearing with me while I sorted myself out.
> > 
> > Cheers,
> > -- 
> > Manfred
> > _______________________________________________
> > Boost-users mailing list
> > Boost-users <at> lists.boost.org
> > http://lists.boost.org/mailman/listinfo.cgi/boost-users
>  		 	   		  
> _________________________________________________________________
> Download nu eenvoudig leuke Emoticons voor je Messenger GRATIS
> http://www.rulive.nl/aspx/emoticons.aspx
Anthony Williams | 1 Jun 2010 08:48
Picon

Re: upgrade_to_unique_lock doesn't compile with vc2010

Braden McDaniel <braden <at> endoframe.com> writes:

> Using Boost 1.43, this program:
>
>         # include <boost/thread.hpp>
>         
>         int main()
>         {
>           boost::shared_mutex mutex;
>           boost::upgrade_lock<boost::shared_mutex> lock(mutex);
>           boost::upgrade_to_unique_lock<boost::shared_mutex> write_lock(lock);
>         }
>
> ... produces this error when compiled with Visual C++ 2010: 

That is trac issue 2501. It was fixed post 1.43, so should be in 1.44.

Anthony
--

-- 
Author of C++ Concurrency in Action     http://www.stdthread.co.uk/book/
just::thread C++0x thread library             http://www.stdthread.co.uk
Just Software Solutions Ltd       http://www.justsoftwaresolutions.co.uk
15 Carrallack Mews, St Just, Cornwall, TR19 7UL, UK. Company No. 5478976
Tore Halvorsen | 1 Jun 2010 12:24
Picon

Re: [Random] random_device and windows - multiply defined symbols

On Mon, May 31, 2010 at 7:00 PM, Steven Watanabe <watanabesj <at> gmail.com> wrote:
>
> Use a shared library or apply the patch from
> https://svn.boost.org/trac/boost/changeset/62347/branches/release/libs/random/src/random_device.cpp

Works great :)

Thanks.

--

-- 
Eld på åren og sol på eng gjer mannen fegen og fjåg. [Jøtul]
<demo> 2010 Tore Halvorsen || +052 0553034554
Manfred Doudar | 1 Jun 2010 13:37
Picon
Picon

[mpl][fusion] iteration over mutiple containers


Hello,

I've been using the Boost.PP lately, and everything now works rather
nicely, but there's been a thing in the back of my head that has
always been telling me, that the problem is better suited to mpl/fusion.
The problem in this case is I have "two things" that need to be iterated
over, one a series of tags (aka "types"), and the the other, a runtime
index.

I'll express what I'm after with mpl::for_each, because the issue
becomes clearer that way:

  using namespace boost;

  //Func:  is an object that facilitates visitation on algorithms

  template <template <typename> Visitor>
  struct Func
  {
      typedef void result_type;

      template <typename R, typename A>
      result_type
      operator()(A* algo)
      {
           // do work.. visit algo, with Visitor<R>

           apply_visitor(std::move(Visitor<R>()), *algo, ...); 
      }
  }

  // tags are the return type on visitation
  typedef mpl::vector<int, float> tags;

  // container of algorithms
  Ctr<algorithms> ctr;

  Func<MyVisitor> ftor;
  mpl::for_each<tags>(bind(ref(ftor),
                           ::_1,              // [A]
                           ctr[INDEX])));     // [B]

[A]:  dispatch the tag
[B]:  pass through algorithm instance at INDEX.. I want to do INDEX++

Of course the problem here is that I can't update INDEX in each
mpl::for_each call, .. and thinking boost::fusion might be the
machinery I need, but I seemingly run into other problems with that
one too, there, since my tag-types are not of the same sequence as my
container of algorithms.

What I want is to pass in the appropriate tag, for each instance of
algorithm from a container.

Indeed, for those wondering, I have tried a typedef on each
algorithm, ..was hoping I could access the nested type A::type in place
of R in Func above, however, owing to the visitation mechanism, doing
so gives problems of access to incomplete-types elsewhere in the chain.

If anyone can suggest something, I'd be happy to hear it, ...as I said,
what I have already works, but I have a hard time letting this one
rest, knowing that there is a better alternative, but am not quite
seeing it yet.

Cheers,
--

-- 
Manfred
Manfred Doudar | 1 Jun 2010 13:44
Picon
Picon

Re: [mpl][fusion] iteration over mutiple containers


I may have confused some with my last post, ..but the mpl::for_each
invocation doesn't align with the function call-operator of Func,
rather, you'd rewrite Func's callable operator appropriately to match
the for_each invocation.

What I have today is a call like:

   Func<MyVisitor> ftor(...);
   ftor.operator()<tag, Algo_type>(Ctr[index]);

Hope that kind of clarifies what may have been cause for some confusion.

Looking forward to what others can say here..

--Manfred

On Tue, 1 Jun 2010 21:37:33 +1000
Manfred Doudar <manfred.doudar <at> rsise.anu.edu.au> wrote:

> 
> Hello,
> 
> I've been using the Boost.PP lately, and everything now works rather
> nicely, but there's been a thing in the back of my head that has
> always been telling me, that the problem is better suited to
> mpl/fusion. The problem in this case is I have "two things" that need
> to be iterated over, one a series of tags (aka "types"), and the the
> other, a runtime index.
> 
> I'll express what I'm after with mpl::for_each, because the issue
> becomes clearer that way:
> 
> 
>   using namespace boost;
> 
>   //Func:  is an object that facilitates visitation on algorithms
> 
>   template <template <typename> Visitor>
>   struct Func
>   {
>       typedef void result_type;
> 
>       template <typename R, typename A>
>       result_type
>       operator()(A* algo)
>       {
>            // do work.. visit algo, with Visitor<R>
> 
>            apply_visitor(std::move(Visitor<R>()), *algo, ...); 
>       }
>   }
> 
> 
> 
>   // tags are the return type on visitation
>   typedef mpl::vector<int, float> tags;
> 
>   // container of algorithms
>   Ctr<algorithms> ctr;
> 
>   Func<MyVisitor> ftor;
>   mpl::for_each<tags>(bind(ref(ftor),
>                            ::_1,              // [A]
>                            ctr[INDEX])));     // [B]
> 
> 
> 
> [A]:  dispatch the tag
> [B]:  pass through algorithm instance at INDEX.. I want to do INDEX++
> 
> 
> Of course the problem here is that I can't update INDEX in each
> mpl::for_each call, .. and thinking boost::fusion might be the
> machinery I need, but I seemingly run into other problems with that
> one too, there, since my tag-types are not of the same sequence as my
> container of algorithms.
> 
> 
> What I want is to pass in the appropriate tag, for each instance of
> algorithm from a container.
> 
> 
> Indeed, for those wondering, I have tried a typedef on each
> algorithm, ..was hoping I could access the nested type A::type in
> place of R in Func above, however, owing to the visitation mechanism,
> doing so gives problems of access to incomplete-types elsewhere in
> the chain.
> 
> 
> If anyone can suggest something, I'd be happy to hear it, ...as I
> said, what I have already works, but I have a hard time letting this
> one rest, knowing that there is a better alternative, but am not quite
> seeing it yet.
> 
> 
> Cheers,
Mathieu Malaterre | 1 Jun 2010 15:12
Picon

boost:any/boost::variant for integral/floating type

Hi,

  I am looking at boost::any and boost::variant which seems to be very
usefull additions to C++ for building heterogenous containers.
  However in my case I need to build something that would be:
- type safe
- can only contains integral/floating type
- allow operations such as max() / min()

My typical operation on this 'generic_value_type' is simply `+= 1`.
boost::any seems difficult to use, since you need to call any_cast any
time you want to operate on the value.

I am thinking I could just wrap boost::variant inside a custom class,
and add my missing functionalities, something like:

struct AttributeValue
{
private:
  struct add_one_visitor
    : public boost::static_visitor<>
    {
    template <typename T>
      void operator()(T & i) const
        {
        i++;
        }
    };
  struct get_min_visitor
    : public boost::static_visitor<>
    {
    template <typename T>
      T operator()(T & i) const
        {
        return std::numeric_limits<T>::min();
        }
    };

public:
  AttributeValue& operator++() {
    boost::apply_visitor( add_one_visitor(), Value );
    return *this;
  }
  AttributeValue min() {
    return boost::apply_visitor( get_min_visitor(), Value );
    }
  boost::variant<double, char, int> Value;
};

Did I miss anything in boost ? Is boost::variant my best option (when
only using fundamental types) ?

Thanks
--

-- 
Mathieu
Uthpal Urubail | 1 Jun 2010 11:40
Favicon

multi_index_container for composite key

Hi

How could I loop through the container to get all the keys.

Eg:

      For(int i=0;i< beambook.count();++i)

Or

      Beambook:: iter1 = beambook.begin(), iter2 = beambook.end();

 

My requirement is to loop through the size and list compositeKey vs list of element Ids

 

Thanks,

UJ   

 

// define a multi_index_container with a composite key on

typedef multi_index_container<

    Beam_entry,

    indexed_by<

    //non-unique as some  might have more than ids

    ordered_non_unique<

        composite_key<

            Beam_entry,

            member<Beam_entry,unsigned int,&Beam_entry::pid>,

            member<Beam_entry,double,&Beam_entry::orientX>,

            member<Beam_entry,double,&Beam_entry::orientY>,

            member<Beam_entry,double,&Beam_entry::orientZ>,

            member<Beam_entry,double,&Beam_entry::OffsetA>,

            member<Beam_entry,double,&Beam_entry::OffsetB>

            >

    >,

    ordered_unique<

    member<Beam_entry,unsigned int,&Beam_entry::eid>

    >

    >

> beambook;

_______________________________________________
Boost-users mailing list
Boost-users <at> lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Gaurav N Shah | 1 Jun 2010 14:00
Picon

Regarding use of Boost.Test in Iteration.

Hi,

I am presently developing a tool to execute a set of test cases after specified time duration (let's say a monitoring tool).

 

Following is the sample code I have written:

 

 

bool init_test()

{

      boost::unit_test::test_suite* ts1 = BOOST_TEST_SUITE( "test_suite1" );

            return false;

      }

 

      TestSuite* testSuite = new TestSuite("TestSuite1"); //TestSuite Class is derived from boost::unit_test::test_suite

      if (!testSuite->initialize())

      {

            LOG(SDK_ERROR, "Failed to initialize testSuite");

            return false;

      }

      ts1->add(testSuite);

      ::boost::framework::master_test_suite().add(ts1);

      return true;

}

 

int main(int argc, char *argv[])

{

      while (1)

      {

            boost::unit_test::unit_test_main(&init_test, argc, argv);

            ::Sleep(2*60*1000); //wait for 2 mins

      }

}

 

It works fine on first attempt. However, on second term after ::Sleep() is over and program try to register &init_test I get following ERROR:

 

Fail to process runtime parameters: Definition of parameter auto_start_dbg conflicts with defintion of parameter auto_start_dbg

Usage:

MarketDataCheck.exe [{--auto_start_dbg=|-d }[yes|y|no|n]] [--break_exec_path=<value>] [{--build_info=|-i }[yes|y|no|n]] [{--catch_system_errors=|-s }[

yes|y|no|n]] [--detect_fp_exceptions=[yes|y|no|n]] [--detect_memory_leaks=<value>] [{--log_format=|-f }<value>] [{--log_level=|-l }<value>] [{--output

_format=|-o }<value>] [{--random=|-a }[<value>]] [{--report_format=|-m }<value>] [{--report_level=|-r }<value>] [{--result_code=|-c }[yes|y|no|n]] [{-

-run_test=|-t }<value>] [--save_pattern=[yes|y|no|n]] [{--show_progress=|-p }[yes|y|no|n]] [--use_alt_stack=[yes|y|no|n]] [{--help=|-? }[yes|y|no|n]]

 

Would you please provide the reason for this error??

If I am not using Boost.Test in correct manner, please suggest any alternative way to use same Boost.Test in iteration mode.

 

(Let me know in case more info is required to debug this problem)

 

Thank You,

Gaurav

This communication is for informational purposes only. It is not intended as an offer or solicitation for the purchase or sale of any financial instrument or as an official confirmation of any transaction. All market prices, data and other information are not warranted as to completeness or accuracy and are subject to change without notice. Any comments or statements made herein do not necessarily reflect those of JPMorgan Chase & Co., its subsidiaries and affiliates. This transmission may contain information that is privileged, confidential, legally privileged, and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. Although this transmission and any attachments are believed to be free of any virus or other defect that might affect any computer system into which it is received and opened, it is the responsibility of the recipient to ensure that it is virus free and no responsibility is accepted by JPMorgan Chase & Co., its subsidiaries and affiliates, as applicable, for any loss or damage arising in any way from its use. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you. Please refer to http://www.jpmorgan.com/pages/disclosures for disclosures relating to European legal entities.

_______________________________________________
Boost-users mailing list
Boost-users <at> lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users

Gmane