[Insight-users] itkSTLContainerAdaptorTest - fix for Borland
Dean Inglis
dean.inglis@on.aibn.com
Wed, 27 Nov 2002 12:53:26 -0500
Hi,
1) Is the templating over the std::container (hiding by private
inheritance) meant to add SmartPointer functionality to
the std::container? If no, why not just use the std::containers
as they are?
anyway, making them public derivations without the
incorrect fix gives:
Changing directory into c:\Builder\itkRelease\Testing\Code\Common
Testing itkSTLContainerAdaptorTest Passed
Testing the VectorContainer ----- Testing non-const Adaptor
VectorContainer (009852C8)
Reference Count: 1
Modified Time: 1
Debug: Off
Observers:
none
Testing assignment... Passed !
Testing index access... Passed !
----- Testing const Adaptor
Testing reading assignment... Passed !
Testing index access... Passed !
VectorContainer test passed !
Testing the MapContainer
----- Testing non-const Adaptor
MapContainer (009858D8)
Reference Count: 1
Modified Time: 3
Debug: Off
Observers:
none
Testing assignment... Passed !
Testing index access... Passed !
----- Testing const Adaptor
Testing reading assignment... Passed !
Testing index access... Passed !
MapContainer test passed !
The following tests passed:
itkSTLContainerAdaptorTest
100% tests passed, 0 tests failed out of 1
2) do the default std::allocator(s) in a given std::container
need to be fleshed out explicitly for Borland? see for e.g.,
http://www.itk.org/cgi-bin/cvsweb.cgi/Insight/Code/Algorithms/itkLaplacianSe
gmentationLevelSetImageFilter.h?cvsroot=Insight&sortby=date
revison 1.3
making
Dean
-----Original Message-----
From: Luis Ibanez [mailto:luis.ibanez@kitware.com]
Sent: November 27, 2002 12:26 PM
To: Dean Inglis; ofri@cs.jhu.edu
Cc: Insight Users
Subject: Re: [Insight-users] itkSTLContainerAdaptorTest - fix for
Borland
Hi Dean, Ofri,
Dean, thanks for looking for a fix for Borland.
Unfortunately gcc doesn't like the proposed fix.
There are valid reasons though:
1) Casting to the actual STLContainer is actually
creating a temporary instance of the container
This is bad since the full content is copied
2) The reference to the temporary variable is
returned. The temporary will be long gone by
the time the user gets the reference.
I'm wondering how useful is to have the adaptor here.
We could equally change the private derivation
for public derivation and let all the STL methods
be available.
It seem that the basic difficulty comes from the
fact that the itk containers use double derivation.
Borland seems to have a hard time with it.
Another option is to do the casting on the
adaptor (not in the class itself) and maybe go
through the dark path of "friend".
What do you think ?
Luis
===============================================
Dean Inglis wrote:
> Hi,
>
> can you test (on other platforms) the following casting in
> Insight/Code/Common/itkVectorContainer.h: lines 103, 107
>
> /** Cast the container to a STL container type */
> STLContainerType & CastToSTLContainer() {
> return static_cast<STLContainerType
> &>(static_cast<STLContainerType>(*this)); }
>
> /** Cast the container to a const STL container type */
> const STLContainerType & CastToSTLConstContainer() const {
> return static_cast<const STLContainerType
> &>(static_cast<STLContainerType>(*this)); }
>
> and
> Insight/Code/Common/itkMapContainer.h: lines 95, 99
>
> /** Cast the container to a STL container type */
> STLContainerType & CastToSTLContainer() {
> return static_cast<STLContainerType
> &>(static_cast<STLContainerType>(*this)); }
>
> /** Cast the container to a const STL container type */
> const STLContainerType & CastToSTLConstContainer() const {
> return static_cast<const STLContainerType
> &>(static_cast<STLContainerType>(*this)); }
>
>
> A ctest -R run of the test gives:
>
> Changing directory into c:\Builder\itkRelease\Testing\Code\Common
> Testing itkSTLContainerAdaptorTest Error, iteration on containers
didn't
> finished simultaneously
> ***Failed
> Testing the VectorContainer ----- Testing non-const Adaptor
> VectorContainer (009852C8)
> Reference Count: 1
> Modified Time: 1
> Debug: Off
> Observers:
> none
>
> Testing assignment... Passed !
> Testing index access...
>
>
>
> 0% tests passed, 1 tests failed out of 1
>
> The following tests FAILED:
> itkSTLContainerAdaptorTest
>
>
> regards,
> Dean
>
>
> _______________________________________________
> Insight-users mailing list
> Insight-users@public.kitware.com
> http://public.kitware.com/mailman/listinfo/insight-users
>
>