ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> boost
boost
[boost] Re: Re: Proven ptr<>
by David B. Held other posts by this author
Aug 12 2002 7:22PM messages near this date
[boost] Re: Re: Proven ptr<> | Re: [boost] Re: Re: Proven ptr<>
"Philippe A. Bouchard" <philippeb@[...].ca>  wrote in message
news:aj8m3k$oce$1@[...]..
>  > I'm not sure if this ptr<> type under discussion works this way, but in
>  > general you can't conformingly use char* arithmetic with offsets to find
>  > the sub-parts of non-POD types.
> 
>  The offsets are what static_cast<>s return.  I cheat in the syntax when I
>  say ptr_base<T, __false_type>::m_ptr is of type T *; it's just to make the
>  code cleaner.

Umm...my understanding is that what Dave is talking about is exactly
what you are doing.  After all, what is the business with
reinterpret_cast<char*>  to do offset arithmetic?

>  [...]
>  template <typename T>
>      struct ptr_block
>      {
>          int m_counter;
>          int m_typeid;
> 
>          union
>          {
>              int;
>              T;
>          } m_object;
>      };
> 
>  But operator new (size_t, rc_type const &) won't be easy to implement
>  because size_t is not a compile-time constant.

I spent a while trying to see if it was possible to make this "invisible
count
wrapper", but ran into the same problem: you need to know the type,
because operator new only provides the size of the type as a runtime
value.  I don't see how you can make a safe, conforming, portable count
wrapper without explicitly naming the type somewhere (like your original
placement new operator which passed in the type).

Dave





_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Thread:
Peter Dimov
Philippe A. Bouchard
David B. Held
David Abrahams
Philippe A. Bouchard
Philippe A. Bouchard
Greg Colvin
David B. Held
Philippe A. Bouchard
David Abrahams
David Abrahams
Philippe A. Bouchard
David Abrahams
Philippe A. Bouchard
Philippe A. Bouchard
Philippe A. Bouchard
Greg Colvin
Philippe A. Bouchard
Greg Colvin
Greg Colvin

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved