Boost find_first, how does it work? / Define a range

I have a buffer (e.g. char buffer[1024]) that is filled with some data. Now I want to find a substring in this buffer. Since this should be a random search, I use boost::algorithm::ifind_first.

Therefore, I call the function as follows:

boost::iterator_range<char*> buf_iterator;
buf_iterator = boost::algorithm::ifind_first(buffer ,"substring");

This works great. But I am worried about the following:

I only pass the function a char pointer, so I ifind_firstdon't have to know where my buffer ends, but it still works tho.

Now my first idea was that the function searches until the line termination character. But in Boost Documentation, a function is defined as follows:

template<typename Range1T, typename Range2T> 
  iterator_range< typename range_iterator< Range1T >::type > 
  find_first(Range1T & Input, const Range2T & Search);

Since it works with template parameters, do I really doubt that it works with zero termination?

, : ifind_first , ? , , ? , char*, , - , , undefined ...

Edit:

, , . , char, , 0...?

+5
1

, , :

template< typename T, size_t L >
void foo( T (&arr)[L] )
{
}

L, foo ( "test" ), foo < char, 5 > (). , const char *, , c-, strlen() .

EDIT: , ifind_first , , .

, ifind_first , char *. , ifind_first , , const char [10] ( "" + 1 NULL). , , const char * ifind_first , NULL, - c, dandy.

char [1024], char *. , char * buffer = new char [1024]; char *, , NULL . ifind_first , , .

, , char [1024] , , , NULL- ( , char [1024], ). , , 12 , NULL, .

+5

All Articles