Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>Where does size_t come from when I don't have anything included in an empty project?</p> </blockquote> <p>If you don't have anything included, then you can't use <code>size_t</code>. It's defined in <code>&lt;stddef.h&gt;</code> (and perhaps also in <code>&lt;cstddef&gt;</code>, if your version of that header puts the definitions in the global namespace as well as <code>std</code>).</p> <blockquote> <p>Is it reasonable to always assume size_t == std::size_t?</p> </blockquote> <p>Yes. All types and functions defined by the C library are included in the <code>std</code> namespace, as long as you include the appropriate C++ header (e.g. <code>&lt;cstddef&gt;</code> rather than <code>&lt;stddef.h&gt;</code>)</p> <blockquote> <p>When should I use std::<strong>_</strong>::size_type?</p> </blockquote> <p>Do you mean the <code>size_type</code> types defined in some standard classes and templates such as <code>vector</code>? You could use those when using those classes if you like. In most cases, you'll know that it's the same as <code>size_t</code>, so you might as well use that and save a bit of typing. If you're writing generic code, where you don't know what the class is, then it's better to use <code>size_type</code> in case it's not compatible with <code>size_t</code>.</p> <p>For example, you might want to write a container designed to hold more items than can be represented by <code>size_t</code>. You might use some kind of big number type to represent the container's size, which isn't convertible to <code>size_t</code>. In that case, code like <code>size_t s = c.size()</code> would fail to compile - you'd need to use <code>Container::size_type</code> instead.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload