This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Shouldn't this code compile?

Tags: None
(comma "," separated)
updogliu
Registered Member
Posts
13
Karma
0
OS

Shouldn't this code compile?

Wed Mar 14, 2012 1:03 am
Code: Select all
#include <boost/make_shared.hpp>
#include <Eigen/StdVector>

struct Apple {
  Apple() : x(81) {}
  int x;
};

int main() {
  typedef Apple type;
  typedef Eigen::aligned_allocator< type > AlignedAllocator;
  boost::allocate_shared< type >(AlignedAllocator());

  return 0;
}
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: Shouldn't this code compile?

Wed Mar 14, 2012 4:12 pm
I don't know boost::allocate_shared but if that's working with a standard allocator, then that should work too. Can you attach the errors.
updogliu
Registered Member
Posts
13
Karma
0
OS

Re: Shouldn't this code compile?

Thu Mar 15, 2012 12:38 am
Compiler: g++ (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2

In file included from /usr/include/boost/smart_ptr/shared_ptr.hpp:32:0,
from /usr/include/boost/smart_ptr/make_shared.hpp:16,
from /usr/include/boost/make_shared.hpp:15,
from /host/Dropbox/codes/testing/trypcl/io/compile.cc:1:
/usr/include/boost/smart_ptr/detail/shared_count.hpp: In constructor ‘boost::detail::shared_count::shared_count(P, D, A) [with P = Apple*, D = boost::detail::sp_ms_deleter<Apple>, A = Eigen::aligned_allocator<Apple>]’:
/usr/include/boost/smart_ptr/shared_ptr.hpp:205:93: instantiated from ‘boost::shared_ptr< <template-parameter-1-1> >::shared_ptr(Y*, D, A) [with Y = Apple, D = boost::detail::sp_ms_deleter<Apple>, A = Eigen::aligned_allocator<Apple>, T = Apple]’
/usr/include/boost/smart_ptr/make_shared.hpp:121:88: instantiated from ‘boost::shared_ptr<X> boost::allocate_shared(const A&) [with T = Apple, A = Eigen::aligned_allocator<Apple>]’
/host/Dropbox/codes/testing/trypcl/io/compile.cc:12:52: instantiated from here
/usr/include/boost/smart_ptr/detail/shared_count.hpp:159:13: error: no matching function for call to ‘Eigen::aligned_allocator<boost::detail::sp_counted_impl_pda<Apple*, boost::detail::sp_ms_deleter<Apple>, Eigen::aligned_allocator<Apple> > >::allocate(int, boost::detail::shared_count::shared_count(P, D, A) [with P = Apple*, D = boost::detail::sp_ms_deleter<Apple>, A = Eigen::aligned_allocator<Apple>]::impl_type*)’
/usr/local/include/eigen3/Eigen/src/Core/util/Memory.h:669:13: note: candidate is: T* Eigen::aligned_allocator<T>::allocate(Eigen::aligned_allocator::size_type, const T**) [with T = boost::detail::sp_counted_impl_pda<Apple*, boost::detail::sp_ms_deleter<Apple>, Eigen::aligned_allocator<Apple> >, T* = boost::detail::sp_counted_impl_pda<Apple*, boost::detail::sp_ms_deleter<Apple>, Eigen::aligned_allocator<Apple> >*, Eigen::aligned_allocator::size_type = unsigned int, const T* = const boost::detail::sp_counted_impl_pda<Apple*, boost::detail::sp_ms_deleter<Apple>, Eigen::aligned_allocator<Apple> >*]
make[2]: *** [io/CMakeFiles/compile.dir/compile.cc.o] Error 1
make[1]: *** [io/CMakeFiles/compile.dir/all] Error 2
make: *** [all] Error 2
updogliu
Registered Member
Posts
13
Karma
0
OS

Re: Shouldn't this code compile?

Thu Mar 15, 2012 12:42 am
This one compiles fine.
Code: Select all
#include <boost/make_shared.hpp>
#include <memory>

struct Apple {
  Apple() : x(81) {}
  int x;
};

int main() {
  typedef Apple type;
  typedef std::allocator< type > StdAllocator;
  boost::allocate_shared< type >(StdAllocator());

  return 0;
}
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: Shouldn't this code compile?

Thu Mar 15, 2012 5:28 pm
hm, which version of eigen do you have ? I've nothing line 669 of Memory.h; neither in 3.0.5 or 3.1-alpha2.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: Shouldn't this code compile?

Thu Mar 15, 2012 5:30 pm
also your example first compiles fine here with 3.0.5 or 3.1.0-alpha2
updogliu
Registered Member
Posts
13
Karma
0
OS

Re: Shouldn't this code compile?

Fri Mar 16, 2012 1:15 am
It was with 3.0.1/3.0.2.
I just updated Eigen to 3.1.0-alpha2, and it works now. Thank you.


Bookmarks



Who is online

Registered users: Bing [Bot], claydoh, Google [Bot], rblackwell, Yahoo [Bot]