[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: C++ string::find functions and size_t
From: |
rik |
Subject: |
Re: C++ string::find functions and size_t |
Date: |
Fri, 27 Feb 2015 10:38:06 -0800 |
On 02/27/2015 10:17 AM, Mike Miller wrote:
> On Fri, Feb 27, 2015 at 09:47:17 -0800, rik wrote:
>> Final question on this topic. According to the C++ reference, the find
>> functions actually return an object of std::string::size_type. Normally,
>> maybe even definitionally, this is the same as std::size_t. Octave code,
>> however, assumes that the bare size_t is the same as std::size_t. Should
>> we care about this? The gl2ps-render.cc code, that maybe we got from
>> somewhere else originally, does use std::size_t.
> Yes, this is absolutely safe. Note that std::string::size_type is in
> fact the same as std::size_t according to the standard. It's
> std::basic_string<c,t,a>::size_type that may differ from std::size_t.
>
Just clarifying, absolutely safe to use bare size_t or absolutely safe to
use std::size_t in place of std::string::size_type?
An example line:
corefcn/dlmread.cc:355: size_t pos1 = line.find_first_not_of
(" \t");
and we don't have a "using namespace std;" line so this is whatever size_t
is picked up. If it is the same as in <cstddef> then we are fine.
--Rik