Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7895003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:32:13+00:00 2026-06-03T07:32:13+00:00

Is using size_t(0) the same as using 0 in the following code? const string

  • 0

Is using size_t(0) the same as using 0 in the following code?

const string foo = "testing";
const size_t pos = foo.find("i");
string name = foo.substr(size_t(0), pos);

That is, when I put only 0 is it converted to size_t(0)? If so, is one form preferred over the other? My guess is that size_t(0) is the best one to use because it makes the conversion explicit. On the other hand, perhaps some programmers consider size_t(0) verbose? I’m guessing in practice no one cares either way.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T07:32:15+00:00Added an answer on June 3, 2026 at 7:32 am

    That is, when I put only 0 is it converted to size_t(0)?

    The conversion is implicit since substr is:

    basic_string substr( size_type pos = 0,
                         size_type count = npos );
    

    Thus your cast is superfluous.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In following code the issue is, that I cannot test dao.add() without using dao.list().size()
if I'm using the sizeof operator and making use of size_t in my code,
i'm using the following code to submit a form: function submitfilter(){ alert(in here); var
I'm using the following working code to decrypt a file: #include <openssl/aes.h> #include <stdio.h>
I'm running the following code on a file that has been uploaded to this
Hi I am using following code in the MAC application for setting font of
I've just started compressing file in VB.Net, using the following code. Since I'm targeting
I've been compiling and using the following code since iOS 4.0: if(UIGraphicsBeginImageContextWithOptions != NULL)
I have following code: typedef enum { FOO, BAR, BAZ } foo_t; static void
Consider the following code: template<size_t head,size_t ... Dims> struct make_vec { typedef typename make_vec<Dims...>::type

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.