$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [boost] Pimpl Again?
From: Vladimir Batov (Vladimir.Batov_at_[hidden])
Date: 2016-05-30 01:42:39
On 2016-05-30 14:18, Gavin Lambert wrote:
> On 30/05/2016 15:16, Vladimir Batov wrote:
>> So, in your view, should we try and have pimpl in Boost? I think we
>> should as it'd be useful IMO...
>
> As I said at the start, yes, I think this has potential usefulness and
> it would be nice to get something like it into Boost.
Excellent.
> ...
> As it's the template specialisation which causes most of my concern,
> my main query is whether it's really necessary or if it could be
> structured differently to avoid this instead.
>
> ... Taking the Book example from the docs...
> ... we get something like this:
>
> namespace library
> {
> namespace detail
> {
> ...
> }
> }
>
> namespace boost
> {
> template<> struct pimpl<library::Book>::implementation
> {
> implementation(string const& the_title,
> string const& the_author)
> : title(the_title), author(the_author), price(0)
> {}
> ...
> bool check_isbn_10_digit() { ... }
> ...
> string title;
> string author;
> int price;
> };
> }
>
> namespace library
> {
> Book::Book(string const& title, string const& author)
> : pimpl_type(title, author)
> {}
>
> string const&
> Book::author() const
> {
> return (*this)->author;
> }
> ...
> }
> ...
Yes, I understand. That's why I said before and still insist now that
that's style... because I personally do not like
namespace library
{
Book::Book(string const& title, string const& author)
: pimpl_type(title, author)
{}
}
as you move your code to the right and IMO just waste the space (you
fill it with blanks instead of the code). So, I write
template<> struct boost::pimpl<library::Book>::implementation
{
....
}
library::Book::Book(string const& title, string const& author)
: pimpl_type(title, author)
{
...
}
Then, you might say you do not like fully qualified
library::Book::Book(), etc... which in my view is, well, style... for me
the "like" and "do not like" are usually the style triggers.