Boost logo

Boost Users :

Subject: Re: [Boost-users] Ranges and primitive arrays and argument forwarding
From: John M. Dlugosz (mpbecey7gu_at_[hidden])
Date: 2011-07-11 09:40:34


Well, it wasn't as bad as I thought. First of all, I had munged the template, and didn't
know that's where the errors were coming from. Corrected, I have

    inline boost::iterator_range<CharT*> measure_fixed (CharT* p, std::size_t capacity)
     {
     // The deduced CharT will include the const if called on a const array.
     CharT* found= std::find (p, p+capacity, CharT(0));
     return boost::iterator_range<CharT*> (p, found);
     }

and then the main function works when declared with references:

    template <typename T>
    size_t Strlen (const T& s)
     {
     return internal::Strlen (internal::as_literal(s));
     }

This blew up originally, so I wrote it as pass-by-value. It turns out that I was getting
a fit from the compiler when the interesting form _was_ being used.

Without &&, I still hope to keep proliferation of arguments down to a minimum because
input arguments can simply always be const, and output arguments never are.

—John


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