incubator-stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Sebor <se...@roguewave.com>
Subject Re: lib.string.capacity test update
Date Fri, 02 Jun 2006 00:06:33 GMT
Martin Sebor wrote:
[...]
> Btw., I'm not sure exactly what other string tests are left but an
> enhancement that still needs to be implemented across several of the
> tests (ctors, append, erase, insert and replace) is exercising the
> exception safety of the member function templates. Since much of the
> exception safety code in the range test functions will be the same
> as the code in the functions testing the ordinary (non-template)
> overloads it would be good to share it to avoid bloat and reduce
> maintenance effort.

FWIW, to make this possible it might be helpful to use the virtual
function approach we successfully applied in some of the algorithms
tests. I.e., have a single test function take as an argument
a reference of some base class for which the range tests will pass
an object of a class template derived from it and specialized on
the type of the iterator.

E.g., something like this:

   template <class charT, class Traits, class Allocator>
   struct ReplaceBase {
       virtual void
       operator()(std::basic_string<...> &str,
                  /* ... */,
                  const StringTestCaseData<charT>&) const {
           // ...
           switch (tdata.func.which) {
           // ... handle all non-template overloads
           }
       }
   };

   template <class charT, class Traits, class Allocator, class Iterator>
   struct ReplaceRange: ReplaceBase<...> {
       virtual void
       operator()(std::basic_string<...> &str
                  /* ... */,
                  const StringTestCaseData<charT>&) const {
           // ...
           switch (tdata.func.which) {
           // ... handle all template overloads
           }
       }
   };

We might want to have multiple overloads of operator() in the
base class, one for each overload of the string function. Or,
if it would make things simpler, we can have just one and have
the caller set up all the arguments just as it does now and
simply pass them to the operator. This approach might involve
fewer changes. We'll see when we try it.

Martin

Mime
View raw message