« first day (2835 days earlier)      last day (24 days later) » 

6:12 AM
is 8 byte alignment, the biggest alignment in c++??
 
6:51 AM
I don't think it's fixed, mostly 8 or 16 en.cppreference.com/w/c/types/max_align_t
plus "over-aligment" or "extended alignment" ist sopported optionally
I mean some simd types have to be 16 byte aligned (and maybe some 32)
 
oh i forgot about simd
 
the C++ standart doesn't really mention them yet, I think the simd proposal wasn't voted in yet
so pretty much everything simd is implementation defined for now
 
oh so the intrinsic library is not part of the standard?
 
nah, that's just something Intel made and most compilers provide. Or in the case of NEON, somehting ARM made.
 
one question about c alignment, i made a struct A of size 5(1 alignment) and when i used it in a second struct B and i noticed that the compiler in struct B doesn't care about struct A size for struct B alignment, it care about it's alignment.
is this how alignment is calculated in C++?
if struct A is 8 aligned, struct B 8 aligned
if struct A is 4 aligned, struct B is 4 unless struct B has 8 aligned variable, then it will be 8 aligned, etc
 
 
6 hours later…
1:07 PM
@ma1169 alignment rolls up generally a size of 5 would align to 8 generally if 8 is the most aligned for that platform
 
The code snippet below is seen at [cppreference](https://en.cppreference.com/w/cpp/container/vector/insert).

My question is why the std::vector::begin() is invalid when the third time to insert.
#include <iostream>
#include <iterator>
#include <vector>

void print(int id, const std::vector<int>& container)
{
std::cout << id << ". ";
for (const int x : container)
std::cout << x << ' ';
std::cout << '\n';
}

int main ()
{
std::vector<int> c1(3, 100);
print(1, c1);

auto it = c1.begin();
it = c1.insert(it, 200);
 
that does seem weird
I mean practically it's probably right. But I think it's implementation defined what the initial capacity is
 
undefined behavior, the compiler is not required to have guards on the iterators. That's an MSVC debug only thing
but no it is not technically still valid there
it just happens to work
if the vector had reallocated then it would produce even worse undefined behavior
 
1:30 PM
The said code snippet is seen at cppreference. I think it should be legal.
 
cppreference isn't infallible, they can have mistakes as well
oh nvm
it returns the result of the insert and assigns it
I misread that
begin() isn't still valid, it's just not used
 

« first day (2835 days earlier)      last day (24 days later) »