@MartinhoFernandes tropes isn't having the addictive effect on me that it has on some other people, however other places have that effect on me, like reddit
Basically I am creating a base class that will be used for classes stored as a linked list, which are traversed and deleted as dictated by a virtual update() function which returns a bool.
I am wondering if this is the most efficient case (I like the fact that it can be a singley linked list in ...
Since TVTropes is just another wiki, though very popular, I'd propose it for inclusion on the list of things that get oneboxed in the SO chat similar to how Wikipedia is oneboxed.
Time to take cover?
The spec says that at phase 1 of compilation
Any source file character not in the basic source character set (2.3) is replaced by the universal-character-name that designates that character.
and at phase 4 it says
Preprocessing directives are executed, macro invocations are expanded
a...
@MartinhoFernandes Yes, they are. The dates are clickable.
Maybe this is a recent change that SE Modifications has hidden from me
mmmm... yes, there we go. SE Modifications made the dates clickable. So there really isn't explicit support for links to comments. You have to hack the ID out of the source. How lame!
@MartinhoFernandes Only when I hit a palindrome, or something at least equally interesting. I once did a couple of spurious downvotes (that I quickly removed) just so I could momentarily hit a perfect number...
@MartinhoFernandes the website is not an actual C++ compiler/parser. it's just parsing the declarator lexically. it has no semantics. Interestingly, it seems to have made an exception for the obvious case of T*&, but in general it's not a tool that tells you what types are valid in C++ [I know it's a C site, but it appears to support C++ with warnings]; it just tells you what the type you're attempting to use says in English.
@MartinhoFernandes Put char& f in. It's accepted, with a visual warning that that would be C++.
@Xeo I'm not sure it's a good idea to make more complex declarations more readable. If you have an excessively complex declaration, it's better to simplify it, not change the syntax. typedef is your friend...
@LucDanton It is relevant, because the tool supports it. But let's forget that.
@LucDanton Write char f[2][].
@LucDanton Lexically, its meaning is sound, and the lexical tool cdecl will tell you what that meaning is. Of course the declarator on its own is not actually valid anywhere, so good luck with that.
Please don't misunderstand me. I never said Luc's syntax is wrong. In fact, I was the first person to respond, and I responded with "yea, think so". I'm merely warning against trying to use tools like cdecl.org to prove it.
I can point to a driver, a preprocessor, an assembler, various front-ends, a linker and I'm not sure where to put a cross-compiler in this. I'm okay with calling the whole or parts of it a compiler toolchain or a compiler ecosystem, too.
But I don't see how or where build tools come into this.
I have doubt whether we can do the following or not.
Suppose I have created two instance of class A i.e. obj1 and obj2
and class A has member function as show()
can i use
(obj1+obj2).show();
If yes how?
If no why it is not possible?
Thanks & regards,
Abhineet Agarwal
It's weird; somewhere in my head something is screaming that one can only call const qualified members here, but I still remember this particular idiom.
I now experimented with windows registry, but i deleted a "Create new folder..." from context menu. And now, i have a little problem . In which registry hive this point stored? I want to restore "Create new folder..."
I'm told that, in C++03, temporaries are implicitly non-modifiable.
However, the following compiles for me on GCC 4.3.4 (in C++03 mode):
cout << static_cast<stringstream&>(stringstream() << 3).str();
How is this compiling?
(I am not talking about the rules regarding tem...
@Klaim You certainly can't bind temporaries to ref-to-non-const. But that may be an unrelated thing. It's clear that a mutable reference to a temporary is silly, since you'll get an immediate dangling reference.
3.10/10: "An lvalue for an object is necessary in order to modify the object except that an rvalue of class type can also be used to modify its referent under certain circumstances. [Example: a member function called for an object (9.3) can modify the object. ]"
"It's clear that a mutable reference to a temporary is silly, since you'll get an immediate dangling reference." - that's one of those cyclic things... if the Standard required their lifetime be extended as per consts, then it wouldn't be silly :-)
@StackedCrooked No, rvalues aren't implicitly const. There are const rvalues (like the call of a function that returns a const std::string) and non-const rvalues (like the call of a function that returns a std::string).
From 3.10.10 / An lvalue for an object is necessary in order to modify the object except that an rvalue of class type can also be used to modify its referent under certain circumstances. [Example: a member function called for an object (class.mfct) can modify the object. ]
So, objects of class type are the exception... :-)
@MartinhoFernandes you mean that PATH variable which is also used for executables? Doesn't seem to works.. I found the directories in the properties folder, but what about just including it in the binary when building?
I'm told that, in C++03, temporaries are implicitly non-modifiable.
Wrong. Temporaries are created by evaluating rvalues, and there are both non-const rvalues and const rvalues. The value category and the constness of an expression are mostly orthogonal 1. Observe:
std::string foo();
...
@Tomalak: yes, I think 3.10/10's relevance is in confirming the general expectation people have from builtin types, and that it explicitly doesn't apply to objects....
@FredOverflow The caveat is that the discussion stemmed out of a specific use of calling member function on an rvalue, which is allowed as a sort of exception to the rule
@Tony: It doesn't need to be the case, because we have the exceptional statement that member functions may modify the object.
I don't know what the other "certain circumstances" are.
Anyway, the answer is, "changing the wording slightly for the conclusion, objects, as accessed through member functions, are not inherently non-modifiable".
What I'm peeved about is that AFAICT the Standard is saying nothing: how can one attempt to modify an rvalue of class type? The rules about reference binding are enough to restrict what is or is not doable, combined with the signatures of the implicitly declared special members (if/when) applicable.
Although IIRC T().i 'inherits' rvalue-ness with C++0x; so perhaps in C++03 the paragraph applies here.
@Tomalak: "why would that be the case?"... the language has a way for the programmer to specify that they don't want a modifiable object returned (a const return object), but why not let the programmer decide? In some particular cases, the programmer may find it extremely convenient to perform chained modifications to results of expressions, building up a one-off value for a function argument etc.. Why restrict that arbitrarily?
For builtins, the language needs to provide a one-size-fits-all behaviour and opts for safety.
@Tomalak: yes, I think 3.10/10's relevance is in confirming the general expectation people have from builtin types, and that it explicitly doesn't apply to objects....
@TomalakGeretkal I do not consider the paragraph necessary to mandate the behaviour of the snippet. But I'm afraid I'd need to dive into the Standard to substantiate that.
At 3.10/10, the standard says:
An lvalue for an object is necessary in order to modify the object except that an rvalue of class type can also be used to modify its referent under certain circumstances. [Example: a member function called for an object (9.3) can modify the object. ]
So, rval...
This seems to be accepted:
struct T {
int x;
};
int main() {
T().x = 3;
}
Though I'm slightly surprised, because IIRC the LHS of op= must be an lvalue, yet the following implies that even T().x is an rvalue:
struct T {
int x;
};
void f(int& x) {
x = 3;
}
int main() {
f(T...
@MartinhoFernandes Perhaps you should change the title to mention temporary objects or rvalues because there's already one answer that has been mislead