Anonymous
NTTP should have structural type
Anonymous
cNTTP should have literal type with additional constraints (which is a special case of structural type)
olli
well yeah sure, I was considering the second paragraph as a statement and question of its own. And for a type to be considered literal it does not need to have public members.
Anonymous
Definitely
MᏫᎻᎯᎷᎷᎬᎠ
Where did it say the part about public and not mutable?
Here In the limitations explained section: https://ctrpeach.io/posts/cpp20-class-as-non-type-template-param/ The blog just guessed the reason and wasn't sure about it And here also https://en.cppreference.com/w/cpp/language/template_parameters
Anonymous
Well the reason probably is that compiler have to cache instantiated templates
Anonymous
And the compiler should know how to compare template arguments
Anonymous
And the easiest way to do it right now is to constraint to all public members
MᏫᎻᎯᎷᎷᎬᎠ
Can't the compiler see private data or what? Joke
Anonymous
What is that?
template <typename T> void foo() {} &foo<int> == &foo<int>
MᏫᎻᎯᎷᎷᎬᎠ
template <typename T> void foo() {} &foo<int> == &foo<int>
I think the reason is not related to any semantic meaning, but for programmers to not getting a very non-clear error message for their non-type parameters confliction, since there is a case when someone would just pass a complex instance I dunno
Anonymous
It's more likely to say "your members must be public so you should not keep internal state so anyone can break it of we just make your members public"
Anonymous
Maybe it doesn't make any sense
Anonymous
But compiler cannot rely to user-provided operator==
MᏫᎻᎯᎷᎷᎬᎠ
Yeah
MᏫᎻᎯᎷᎷᎬᎠ
But compiler cannot rely to user-provided operator==
They can provide the same param under the hood Dirty hacks
Anonymous
So for example if you make all of std::string's member public you cannot really compare two strings member by member
Anonymous
publicity of member may also mean "all your state must be directly in an object"
Anonymous
I think they will "unconstraint" it in future standards when they will find the way to do it properly
MᏫᎻᎯᎷᎷᎬᎠ
Yup
Andrea
hello I would need help on a game that I am playing with curses in c, using processes and pipes, sorry for the English but I am Italian
j
when we are passing a vector to a funcition, why do we have to specify an & at the paramenters of the function? shouldnt we put an * instead?
Anonymous
Hi,i want to know how to write choose menu number 1 if the value r=4,i=4,v=2 in the code block?
King Phyte 🐍
Hi,i want to know how to write choose menu number 1 if the value r=4,i=4,v=2 in the code block?
if ((r==4) && (i==4) && (v==2)) { int menu_option = 1; // Of course, I'm assuming a lot of things }
Anonymous
How can I send a function as a paramter to another one? MainWindow::GetData(QUrl("http://google.com"), &MainWindow::ShowPost); Here is my function: void MainWindow::GetData(QUrl url, void (* callback)(QNetworkReply * reply)) But it returns error
Anonymous
std::function
Can you make an example with the things that I pasted? 😁
Anonymous
Type mismatch perhaps
Hmmm, I think you're right. I'm trying to receive a pointer to a global function, but I send a class method address to that pointer. What am I supposed to do to fix this issue?
Vlad
Kinda hacky but should work
Anonymous
Vlad
Thanks. Got it
But you gotta remember that capture by the reference is dangerous for a callback
Anonymous
Good morning
nandha
Ya..I'm agree
Артём
Can I forbid to bind a reference to my object?
Артём
I mean, how can I define such class, to whose object cannot be bound a reference?
Anonymous
they tried c++ for kernel, it does not work. also I`ve heard exceptions are disabled for Web Browser for example.
I am sorry for returning to an old flame, but Linus was debunked here https://github.com/SerenityOS/serenity/tree/master/Kernel Everything here is written in C++
Roshan
Can someone give a brief idea of what is STL and all its components?
Igor🇺🇦
Can someone give a brief idea of what is STL and all its components?
Haven't you heard of Wikipedia? https://en.wikipedia.org/wiki/Standard_Template_Library
Roshan
I am learning STL and wanted to just know how big it is.
Igor🇺🇦
I wanted a small and compact answer BTW...
This was small and compact answer. This is the full answer https://en.cppreference.com/w/cpp
Igor🇺🇦
Can I forbid to bind a reference to my object?
Reference to an object is just another name. Why would you want disabling naming an object? How do you that object to be handled without a reference?
Anonymous
Google for types of member functions in C++
Anonymous
But as Vlad advised you, I'd change type to std::function and pass the lambda as the callback
سلطان
can anyone recommand for my a plan for advanced C/C++ program because i need learn more 🤘🏻
Anonymous
2.
سلطان
thanks👍🏻❤️
Xudoyberdi
Anonymous
Blue
Why i cant run
How are we supposed to know if we dont see the error message?
Anonymous
Blue
Meanss what?i'm so blur right now
You asked "Why I cant run" after being given a solution to your question. Did your program execute successfully or no?
King Phyte 🐍
Why i cant run
I did say I was assuming a lot of things So maybe you would show the error message and or the code first
Soldier_OF_Mahdi1998
Hi there :) ahm sorry to interrupt you but may you check my codes to see why it goes on and on without taking user input ? in my function i added cin but code goes without taking userinput
Anonymous
https://pastebin.com/MCDfnJ09
YUSUF
Why i cant run
If(r==4&&i==4&&v==2) { } now this can run
Roshan
What happens when I do this? Stringstream ss; ss << str1; ss >> a; ss << str2; // What happens here?? ss >> b;
ברני
Hey stupid math question that I forgot... How do I devide 2 numbers with minus only? 😞(on C)
ברני
Hey stupid math question that I forgot... How do I devide 2 numbers with minus only? 😞(on C)
while(num>0){ num3=num1-num2; counter++; num=num3; } I think something is off here
A_Z
Hi Folks! Please suggest some resources to learn C Programming along with basic Projects. Thanks Folks.
Roshan
while(num>0){ num3=num1-num2; counter++; num=num3; } I think something is off here
int a = 6, d = 3, i = 0; while(a != 0){ a-=d; i++; } cout<<i; //Or printf();
Roshan
For the numbers that are divisible.
Roshan
For the numbers that are divisible.
Or basically the integer part of answer
Артём
Reference to an object is just another name. Why would you want disabling naming an object? How do you that object to be handled without a reference?
Actually no practice needs, but I have got interesting idea to define such class, whose objects cannot be passed as arguments to any function. Now okey, I can define copy and move ctors as deleted to forbid passing it by value. How do I do it in case of passing by reference?
Артём
I tried to redefine operator& (getting address of) as deleted, so I only prevent from creating pointers to my objects. Creating references seems to work another way, not like through getting address of var.
Anonymous
OMG
Anonymous
I haven't looked for English