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 7808603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:10:59+00:00 2026-06-02T03:10:59+00:00

I have a question on the implementation of vector in EASTL . The link

  • 0

I have a question on the implementation of vector in EASTL.
The link is here.

Namely, on the method size(). Here is what it looks like:

template <typename T, typename Allocator>
inline typename vector<T, Allocator>::size_type
vector<T, Allocator>::size() const
{
    return (size_type)(mpEnd - mpBegin);  
}

size_type is uint32_t, mpBegin/mpEnd are T* pointers.

I do not understand how the cast to uint32_t from (mpEnd – mpBegin) equals the number of elements in a vector. Shouldn’t it be divided by sizeof(T)? Otherwise we just get the size in bytes of all the elements in the vector?

What am I missing?

EDIT: Unless, the EASTL vector dosn’t follow the stl defintion of a vector, but I couldn’t find any data on it and its supposedly be possible to replace stl vector with eastl vector

  • 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-02T03:11:00+00:00Added an answer on June 2, 2026 at 3:11 am

    It’s not the cast that causes the operation to equal the number of elements in the array. Pointer subtraction already does the right thing here. When you subtract one pointer from another, the size of the types they point to is taken into account. There is no need to divide by sizeof(T). It has always been this way, even in C. The cast simply converts it to the right integer type for the return value, if it’s not already.

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

Sidebar

Related Questions

I have a question about communication between activities on implementation program of Android. Here
I have a question regarding my database design and its implementation that i am
In relation to this question ( Efficient hashCode() implementation ) I have one more
This question may seem a little bit stackoverflow-implementation specific, but I have seen a
I have question about parsing in Html helper : I have sth like: @foreach
A different question inspired the following thought: Does std::vector<T> have to move all the
this question is just speculative. I have the following implementation in C++: using namespace
I have a question relating to the use of an Initialization Vector in AES
I have a function that converts from my own implementation of a 3D vector
I have an implementation question. I am trying to have a rectangle change color

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.