Boost logo

Boost Users :

From: Duane Murphy (duanemurphy_at_[hidden])
Date: 2005-07-07 23:55:37


I'm trying to define a custom sequence for use by the replace_all()
function of boost::string::algo. I'm hitting an error that I am not able
to decipher the cause of.

In the Finder concept check in find_format.hpp (Line 238), I'm getting
two errors:
Error : illegal template argument(s)
 (point of instantiation: 'SpecifyItem(const unsigned char *, const
unsigned char *, bool)')
  (instantiating: 'boost::algorithm::replace_all<sequence, const
unsigned char *, const unsigned char *>(sequence &, const unsigned char
*const &, const unsigned char *const &)')
   (instantiating: 'boost::algorithm::find_format_all<sequence,
boost::algorithm::detail::first_finderF<const unsigned char *,
boost::algorithm::is_equal>, boost::a
lgorithm::detail::const_formatF<const unsigned char *>>(sequence &,
boost::algorithm::detail::first_finderF<const unsigned char *,
boost::algorithm::is_equal>, boost::a
lgorithm::detail::const_formatF<const unsigned char *>)')
find_format.hpp line 238 BOOST_STRING_TYPENAME
const_iterator_of<SequenceT>::type> >();

Error : '(' expected
 (point of instantiation: 'SpecifyItem(const unsigned char *, const
unsigned char *, bool)')
  (instantiating: 'boost::algorithm::replace_all<sequence, const
unsigned char *, const unsigned char *>(sequence &, const unsigned char
*const &, const unsigned char *const &)')
   (instantiating: 'boost::algorithm::find_format_all<sequence,
boost::algorithm::detail::first_finderF<const unsigned char *,
boost::algorithm::is_equal>, boost::a
lgorithm::detail::const_formatF<const unsigned char *>>(sequence &,
boost::algorithm::detail::first_finderF<const unsigned char *,
boost::algorithm::is_equal>, boost::a
lgorithm::detail::const_formatF<const unsigned char *>)')
find_format.hpp line 238 BOOST_STRING_TYPENAME
const_iterator_of<SequenceT>::type> >();

The sequence I am defining wraps a Macintosh style Pascal string. (For
those not in the know, these are a string where the first byte is the
length. The character type is also unsigned char.)

I am defining the sequence called sequence:

        class sequence
        {
        public:
                sequence() {}

                sequence( unsigned char* in_sequence )
                : sequence( in_sequence ) {}
        
                typedef unsigned char value_type;
                typedef std::ptrdiff_t difference_type;
                typedef std::size_t size_type;
                typedef unsigned char* iterator;
                typedef const unsigned char* const_iterator;
        
                iterator begin() { return &sequence[1]; }
                const_iterator begin() const { return &sequence[1]; }

                iterator end() { return &sequence[ sequence[0] ]; }
                const_iterator end() const { return &sequence[ sequence[0] ]; }

        private:
                unsigned char* sequence;
        };

This isn't complete, but I thought I could get a little farther than
this or at least understand what I am missing from the definition that
this concept check doesn't fail.

I am using it like this:

void SpecifyItem( unsigned string* in_pascal_string )
{
                sequence seq( in_pascal_string );
                const unsigned char* find_this = "\pa";
                const unsigned char* replace_with = "\pb";
                boost::algorithm::replace_all( seq, find_this, replace_with );
}

I also don't have a copy of the spec to understand all of the
requirements for a sequence, so I was shooting in the dark emulating a
vector to see how for I could get. I expected to get a little farther. :-)

Thanks for any tips,

 ...Duane


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net