|
Boost : |
From: Andrew D Jewell (ajewell_at_[hidden])
Date: 2000-03-16 11:08:10
Let me try, and to make it harder, I'll hold more closely to my real need.
---- Original :
#include <vector>
class A {};
class B {};
// This actually creates a subclass of B, who's declaration I want to hide
B * NewB(const vector<A> & x);
---- New and Improved Version 1:
class A {};
class B {};
B * NewB(const A * begin, const A * end);
template<typename Container>
B * NewB(Container vec)
{return NewB (vec.begin(), vec.end());
* This didn't actually use the construct in question
* And limits you to types whos iterators are really A*
* The only solution that comes to mind forces extra
* generality on B
template<typename Iterator>
B * NewB(Iterator begin, Iterator end)
{
B * value = NewB();
for (Iterator i = begin; i!= end; ++i) {
value->push_back(*i);
}
return value;
}
At 10:44 AM -0500 3/16/2000, Jeffrey D. Paquette wrote:
>I'll admit to being dense here.. could you explain the member template
>technique further, or provide a reference that I could read? How does this
>help?
>
>--
>Jeff Paquette
>paquette_at_[hidden], paquette_at_[hidden]
>http://www.atnetsend.net
>
>
>
>
>-----Original Message-----
>From: Kevlin Henney [mailto:kevlin_at_[hidden]]
>Sent: Thursday, March 16, 2000 10:35 AM
>To: boost_at_[hidden]
>Cc: accu-general_at_[hidden]
>Subject: [boost] Re: How to avoid including <vector>
>
>
>In message <p04310100b4f6a22464d0@[24.29.6.251]>, Andrew D Jewell
><ajewell_at_[hidden]> writes
>[...]
>>class B {
>>public:
>> void f(const vector<A> & inList);
>>};
>[...]
>>To reduce compile time, I would like to avoid saying
>>
>>#include <vector>
>[...]
>>As I see it, my choices include
>>
>>1) Just include <vector> and stop whining
>>2) Change the signature to f(const A * inList, int inListLength)
>>3) Create my own non-portable <stlfwd> which is like <iosfwd> but for
>>stl types.
>
>4) Avoid the issue completely and avoid the restriction on using only
>vector by using member templates:
>
> class B
> {
> public:
> template<typename iterator>
> void f(iterator begin, iterator end);
> ...
> };
>____________________________________________________________
>
> Kevlin Henney Curbralan Ltd
> kevlin_at_[hidden] +44 (0) 7801 073 508
>____________________________________________________________
>
>------------------------------------------------------------------------
>@Backup- Protect and Access your data any time, any where on the net.
>Try @Backup FREE and recieve 300 points from mypoints.com Install now:
>http://click.egroups.com/1/2345/1/_/9351/_/953221100/
>
>-- Easily schedule meetings and events using the group calendar!
>-- http://www.egroups.com/cal?listname=boost&m=1
>
>
>
>
>------------------------------------------------------------------------
>Enjoy 200 FREE Photos including FREE shipping to you, your
>friends & family. Shutterfly delivers beautiful 35mm quality
>prints from your digital camera - ready for frames or photo albums.
>http://click.egroups.com/1/2144/1/_/9351/_/953221537/
>
>-- 20 megs of disk space in your group's Document Vault
>-- http://www.egroups.com/docvault/boost/?m=1
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk