BinaryByter
No, he means trivial default constructor
Well, the deleted constructor is not exactly trivial
MᏫᎻᎯᎷᎷᎬᎠ
Well, the deleted constructor is not exactly trivial
Well std::is_trivial<T> says yes it's
Nomid Íkorni-Sciurus
it can be boiled down to an array-like access operation
Hm... so after the malloc call, I would read the pointer in the registry and then read the field at [ptr_size + field_before_the_one_I_need_size]
BinaryByter
Well std::is_trivial<T> says yes it's
Prolly because the compiler considers it to have a default constructed constructor
Nomid Íkorni-Sciurus
hm, okay, now it's clear
MᏫᎻᎯᎷᎷᎬᎠ
BinaryByter
there is ONE interesting
Liam
In asm level, every variable is mem-address and offset.
BinaryByter
Again The default constructor is deleted
but generated by the compiler
Nomid Íkorni-Sciurus
This is the kind of study I'm looking for. So, GCC + GDB should suffice right?
MᏫᎻᎯᎷᎷᎬᎠ
BinaryByter
void a::b(int a) is assembled to a::b(a* this, int a)
BinaryByter
Wtf?!
Idk how gcc implements its shits
BinaryByter
is_trivial uses compiler intrinsics
MᏫᎻᎯᎷᎷᎬᎠ
Idk how gcc implements its shits
If it does generate a default constructor then why I can't use one
BinaryByter
Meaning that it exposes you directly to the compilers implem
Liam
void a::b(int a) is assembled to a::b(a* this, int a)
not exactly... this pointer may be passed as the last parameter to member functions in some compilers.
MᏫᎻᎯᎷᎷᎬᎠ
BinaryByter
it doesnt matter for my point
Liam
well, yes
Liam
my fault.
BinaryByter
The compiler could pass it in the middle
BinaryByter
Hmm maybe
Idk how gcc implements its shits
BinaryByter
Actually, from what ive read, deleted constructors seem to be defined as trivial
BinaryByter
Oh well
BinaryByter
in practice, this is kinda useless to know
BinaryByter
so 🤷‍♂
Nomid Íkorni-Sciurus
BinaryByter
this group gives me agressions xD
MᏫᎻᎯᎷᎷᎬᎠ
Okay Another question If trivial class is a class that a has a defaulted special member functions Then why there is __is_trivial_copyable(T) built-in function The copy constructor is already there in the ordinary trivial class
MᏫᎻᎯᎷᎷᎬᎠ
Is there a class that doesn't has a copy constructor and trivial at the same time?!
Liam
Headache... A class type is trivial if it's trivially_copyable and it's trivially default constructivle. The later requires the class type has one or more default constructors, all of which are either trivial or deleted, and at least one of which is not deleted. So... struct A { A() = delete; }; is not trivial. however, both gcc and clang give true for std::is_trivial<A>::value.
MᏫᎻᎯᎷᎷᎬᎠ
Like If you deleted one Another one will be provided?!
Liam
It seems that the committee is aware of this problem. > A default constructor that is defined as deleted is trivial, according to 12.1 [class.ctor] paragraph 5. This means that, according to 9 [class] paragraph 6, such a class can be trivial. If, however, the class has no default constructor because it has a user-declared constructor, the class is not trivial. Since both cases prevent default construction of the class, it is not clear why there is a difference in triviality between the cases.
Nomid Íkorni-Sciurus
Hm, I find GCC's assembly output to be less clear than MSVC's
Liam
and also Clang's.
Nomid Íkorni-Sciurus
GCC 8.2
Nomid Íkorni-Sciurus
MSVC 19.10
MᏫᎻᎯᎷᎷᎬᎠ
MᏫᎻᎯᎷᎷᎬᎠ
Thanks
Anonymous
Hi
MᏫᎻᎯᎷᎷᎬᎠ
Hi
بوصَعبْ
Hi
Hello
Anonymous
Hello
Anonymous
hey guys, how can i save long words in one single char or variable?? Ex:- char ch; cin >> ch; /*here i want to enter long words like (my name is ... *\
Anonymous
I've google it, but no good result
Liam
#include <string> int main() { std::string s; std::cin >> s; std::cout << s << std::endl; return 0; }
Anonymous
Thanks bro
joel
what ide is this
Nomid Íkorni-Sciurus
what ide is this
It's not an IDE
joel
what's it
Liam
what's it
https://gcc.godbolt.org/
joel
interesting
MᏫᎻᎯᎷᎷᎬᎠ
https://gcc.godbolt.org/
You can use -S argument
Liam
You can use -S argument
I know. But this website is much more clear.
MᏫᎻᎯᎷᎷᎬᎠ
Lemme check it
MᏫᎻᎯᎷᎷᎬᎠ
Lmao It's blocked from my country xD
MᏫᎻᎯᎷᎷᎬᎠ
Yeah
Anonymous
Yeah
Ur from the Middle East den?
MᏫᎻᎯᎷᎷᎬᎠ
MᏫᎻᎯᎷᎷᎬᎠ
East Africa
Anonymous
East Africa
No doubt dat it is blocked
MᏫᎻᎯᎷᎷᎬᎠ
MᏫᎻᎯᎷᎷᎬᎠ
hey
MᏫᎻᎯᎷᎷᎬᎠ
we can't bind a cosnt lvalue reference to a bare rvalue right?
MᏫᎻᎯᎷᎷᎬᎠ
for example this is not valid const int& r = 1; int&& r1 = std::move(r);
MᏫᎻᎯᎷᎷᎬᎠ
but in std::move implementation it's parameter is move(_Tp&& t) notice that if you pass "r"(which is const lvalue reference) is legal
MᏫᎻᎯᎷᎷᎬᎠ
why?
BinaryByter
The compiler is not as strongly, typed as you may think
BinaryByter
works