Hi All, could anyone make a suggestion to fix the code below? Thanks!
class A{
public:
/* constructor */
double value()const{/* implementation */};
};
typedef std::vector<boost::shared_ptr<A dataset_type;
dataset_type dataset;
/* fill A*/
dataset_type::const_iterator e =
upper_bound(
boost::make_transform_iterator(dataset.begin(),boo st::mem_fn(&A::value))
,boost::make_transform_iterator(dataset.end(),boos t::mem_fn(&A::value))
,1.0
);
Severity and Description Path Resource Location Creation Time Id
/usr/include/c++/4.1.3/bits/stl_algo.h instantiated from
'_ForwardIterator std::upper_bound(_ForwardIterator, _ForwardIterator,
const _Tp&) [with _ForwardIterator =
boost::transform_iterator<boost::_mfi::cmf0<double , A>,
__gnu_cxx::__normal_iterator<boost::shared_ptr<A>* ,
std::vector<boost::shared_ptr<A>, std::allocator<boost::shared_ptr<A>
>, boost::use_default, boost::use_default>, _Tp = double]'
Survival line 2886 1200190279169 231940
Severity and Description Path Resource Location Creation Time Id
/usr/local/boost_1_34_1/boost/iterator/transform_iterator.hpp error:
no matching function for call to 'boost::_mfi::cmf0<double,
A>::cmf0()' Survival line 100 1200190279170 231941
Severity and Description Path Resource Location Creation Time Id
error: conversion from
'boost::transform_iterator<boost::_mfi::cmf0<doubl e, A>,
__gnu_cxx::__normal_iterator<boost::shared_ptr<A>* ,
std::vector<boost::shared_ptr<A>, std::allocator<boost::shared_ptr<A>
>, boost::use_default, boost::use_default>' to non-scalar type
'__gnu_cxx::__normal_iterator<const boost::shared_ptr<A>*,
std::vector<boost::shared_ptr<A>, std::allocator<boost::shared_ptr<A>
>' requested Survival Survival_dist_impl_aggregate_test.cpp line
92 1200190279169 231939 8 4094
On Jan 13, 11:36 am, er <erwann.rog...@gmail.comwrote:
dataset_type::const_iterator e =
upper_bound(
boost::make_transform_iterator(dataset.begin(),boo st::mem_fn(&A::value))
,boost::make_transform_iterator(dataset.end(),boos t::mem_fn(&A::value))
,1.0
)
How about :
e = upper_bound(...).base();
Regards,
On Jan 12, 11:52 pm, shunsuke <pstade...@gmail.comwrote:
On Jan 13, 11:36 am, er <erwann.rog...@gmail.comwrote:
dataset_type::const_iterator e =
upper_bound(
boost::make_transform_iterator(dataset.begin(),boo st::mem_fn(&A::value))
,boost::make_transform_iterator(dataset.end(),boos t::mem_fn(&A::value))
,1.0
)
How about:
e = upper_bound(...).base();
Regards,
Thanks for your help: I have one less error.
But I have 2 errors remaining:
Severity and Description Path Resource Location Creation Time Id
/usr/include/c++/4.1.3/bits/stl_algo.h instantiated from
'_ForwardIterator std::upper_bound(_ForwardIterator, _ForwardIterator,
const _Tp&) [with _ForwardIterator =
boost::transform_iterator<boost::_mfi::cmf0<double , A>,
__gnu_cxx::__normal_iterator<boost::shared_ptr<A>* ,
std::vector<boost::shared_ptr<A>, std::allocator<boost::shared_ptr<A>
>, boost::use_default, boost::use_default>, _Tp = double]'
Survival line 2886 1200236373397 231961
Severity and Description Path Resource Location Creation Time Id
/usr/local/boost_1_34_1/boost/iterator/transform_iterator.hpp error:
no matching function for call to
'boost::_mfi::cmf0<double,A>::cmf0()' Survival line 100 1200236373397
231962
On Jan 14, 12:03 am, er <erwann.rog...@gmail.comwrote:
Survival line 2886 1200236373397 231961
Severity and Description Path Resource Location Creation Time Id
/usr/local/boost_1_34_1/boost/iterator/transform_iterator.hpp error:
no matching function for call to
'boost::_mfi::cmf0<double,A>::cmf0()' Survival line 100 1200236373397
231962
Probably understood.
std::upper_bound needs ForwardIterator, which must be
DefaultConstructible.
But boost::mem_fn(..) is not.
So that, transform_iterator containing boost::mem_fn(..) is not.
Ditto boost::bind.
There seems no trivial workaround.
Regards,
On Jan 13, 4:38 pm, shunsuke <pstade...@gmail.comwrote:
On Jan 14, 12:03 am, er <erwann.rog...@gmail.comwrote:
Survival line 2886 1200236373397 231961
Severity and Description Path Resource Location Creation Time Id
/usr/local/boost_1_34_1/boost/iterator/transform_iterator.hpp error:
no matching function for call to
'boost::_mfi::cmf0<double,A>::cmf0()' Survival line 100 1200236373397
231962
Probably understood.
std::upper_bound needs ForwardIterator, which must be
DefaultConstructible.
But boost::mem_fn(..) is not.
So that, transform_iterator containing boost::mem_fn(..) is not.
Ditto boost::bind.
There seems no trivial workaround.
Regards,
Thanks!
What if I create a Pimpl that wraps around shared_ptr<A>? I guess I
won't need mem_fn anymore. Will go ahead and try that a bit later but
in someone wishes to comment...
On Jan 14, 9:38 am, er <erwann.rog...@gmail.comwrote:
So that, transform_iterator containing boost::mem_fn(..) is not.
Ditto boost::bind.
There seems no trivial workaround.
Regards,
Thanks!
What if I create a Pimpl that wraps around shared_ptr<A>? I guess I
won't need mem_fn anymore. Will go ahead and try that a bit later but
in someone wishes to comment...
Though I don't understand what your Pimpl means,
a non-generic but simple workaround is to write a function-object from
scratch.
struct call_A_value
{
typedef A_value_result_type result_type;
result_type operator()(shared_ptr<Aconst &p) const { return p-
>value(); }
};
Regards,
On Jan 13, 8:16 pm, shunsuke <pstade...@gmail.comwrote:
On Jan 14, 9:38 am, er <erwann.rog...@gmail.comwrote:
So that, transform_iterator containing boost::mem_fn(..) is not.
Ditto boost::bind.
There seems no trivial workaround.
Regards,
Thanks!
What if I create a Pimpl that wraps around shared_ptr<A>? I guess I
won't need mem_fn anymore. Will go ahead and try that a bit later but
in someone wishes to comment...
Though I don't understand what your Pimpl means,
a non-generic but simple workaround is to write a function-object from
scratch.
struct call_A_value
{
typedef A_value_result_type result_type;
result_type operator()(shared_ptr<Aconst &p) const { return p-
value(); }
};
Regards,
Thanks again!
I meant class A_wrap{ public: /* A's functionality*/ private:
shared_ptr<Apimpl;}, just more straightforward to have
vector<A_wrapthan vector<shared_ptr<A, so I have modified
call_A_value accordingly (return ref.value() rather than p->value()).
Your suggestion works, but I'm unclear why I can't instead use
bind(&A_wrap::value,_1)?
Severity and Description Path Resource Location Creation Time Id
error: no matching function for call to
'upper_bound(boost::transform_iterator<boost::_bi: :bind_t<double,
boost::_mfi::cmf0<double, A>, boost::_bi::list1<boost::arg<1(*)()>
>, __gnu_cxx::__normal_iterator<A*, std::vector<A, std::allocator<A , boost::use_default, boost::use_default>,
boost::transform_iterator<A_call_entry_time,
__gnu_cxx::__normal_iterator<A*, std::vector<A, std::allocator<A >,
boost::use_default, boost::use_default>, double)' Survival
Survival_dist_impl_aggregate_test.cpp line 94 1200353623364 233605
On Jan 15, 8:43 am, er <erwann.rog...@gmail.comwrote:
Your suggestion works, but I'm unclear why I can't instead use
bind(&A_wrap::value,_1)?
A FunctionObject which boost::bind(and mem_fn) returns is not
DefaultConstructible,
which ForwardIterator(and its algorithms) requires.
Regards,
On Jan 15, 5:37 am, shunsuke <pstade...@gmail.comwrote:
On Jan 15, 8:43 am, er <erwann.rog...@gmail.comwrote:
Your suggestion works, but I'm unclear why I can't instead use
bind(&A_wrap::value,_1)?
A FunctionObject which boost::bind(and mem_fn) returns is not
DefaultConstructible,
which ForwardIterator(and its algorithms) requires.
Regards,
Got it, thanks. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Ernst Murnleitner |
last post by:
Hello,
in 2 other threads I had questions partly related to shared_ptr.
I changed my normal pointers to a class to shared_ptr. (i.e.
boost::shared_ptr).
I thought, the use of shared_ptr is...
|
by: Ryan Mitchley |
last post by:
Hi all
Given
bool bResult;
shared_ptr<cSampleData> pNewData;
shared_ptr<cBase> pNewBase;
where cSampleData is descended from cBase, the following gives me a valid
pNewData to the correct...
|
by: PengYu.UT |
last post by:
In the following program, I want an iterator contain pointer pointing
to constant object not const pointer. If it is possible would you
please let me know how to do it?
#include...
|
by: myfavdepo |
last post by:
Hi all,
I have a query regarding the exchanging of a
boost::shared_ptr beween different threads. In my program i've two
threads both of which having their own internal queues for storing the...
|
by: Tim H |
last post by:
I understand the semantics of why this works the way it does. But I
wonder if there's a reason for the behaviore at the line marked
"QUESTION". I figured if there is an answer, someone here knows...
|
by: Tim H |
last post by:
Why is the following code not valid? I mean, I see the code and it
doesn't allow it, but I am curious about the rationale?
boost::shared_ptr<intpi = new int;
pi = new int;
Thanks
Tim
|
by: EnsGabe |
last post by:
Suppose you have a class heirarchy as such:
class Base{
....
};
class Mid1 : public Base{
....
|
by: Fokko Beekhof |
last post by:
Hello all,
please consider the following code:
--------------------------------------------------
#include <tr1/memory>
struct BaseA
{
int x;
|
by: .rhavin grobert |
last post by:
are there any pro's and con's in using references to shared_ptr<>'s ?
example:
__________________________________________________
void obj::foo(shared_ptr<>); vs. void...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |