« first day (357 days earlier)      last day (4607 days later) » 

10:00 PM
If A a(c); was a function declaration, what would it mean? What would be the parameter type? As Johannes pointed out, if c is not a type, a cannot be a function.
 
So A() is just
A ()
 
@LucDanton oh wow
 
() nameless function that returns an A object
 
As I already told you, inside a parameter list, A() is rewritten as A(*)().
 
10:02 PM
Honestly, I wouldn't worry too much about that. Unless you stumble upon a problem, just leave it be.
 
I always thought of it as a call to the constructor
 
I wrote C with classes code for 10 years before stumbling onto the problem.
@LewsTherin It is unless it is a function declaration :)
A a();
That's the easiest example. What do you think a is here?
 
a function
declaration
 
Right, a function that takes no arguments and returns an A.
That case you must be aware of, because it happens quite often. All others cases are mostly irrelevant.
 
yeah
 
10:05 PM
The most obscure version is this one:
fstream fin("filename");
vector<int> v(istream_iterator<int>(fin), istream_iterator<int>());
v is a function with a very funny signature :)
 
Jesus, all this time I always looked at them as objects :(
 
Because in 99% of the cases, they are.
Direct initialization of objects. The most vexing parse is a corner case.
 
@FredOverflow v is a ctor, afaik
 
@TonyTheLion Nope, it's a function declaration.
 
it looks like one for sure
 
10:07 PM
v is a function returning a vector of integers and taking two parameters. The first parameter is an iterator named fin, and the second one is an anonymous pointer to a function taking nothing and returning an iterator.
 
In the case of fstream fin("filename"); how does fin act like an object
 
@LewsTherin Oh, fin is an object. I'm talking about v being a function.
 
oh fin is an object because it has no type in front of it
oh ok
so how does v act like an object
 
fin is an fstream object initialized by the fstream constructor taking a const char*.
@LewsTherin I don't understand your question. v is a function declaration, it does not "act like an object" (what is that even supposed to mean?).
 
you can do v.push later on
or something
you can perform send makes to v as if it was an object
 
10:10 PM
Oh you mean, how can I change the declaration so it becomes an object?
 
right?
 
vector<int> v((istream_iterator<int>(fin)), (istream_iterator<int>()));
Note the additional parenthesis. One pair of them should suffice, but I put them on both parameters.
 
I think it shouldn't be necessary if you pass an existing declared name
 
ok lets assume I have a list <Person> b
 
@DeadMG The preexisting name doesn't affect whether it is a valid declaration or not, unfortunately.
 
10:14 PM
and I did b.push(B())
 
Sorry guys, just one question. Let's say I have,

int z = 5;
int *x = &z;
int **y = &x;

Now let's say I want to see the difference in memory addresses of x and y in memory, in a 64-bit system they should now be 8bytes from each other (if the compiler hasn't reordered them in any way).

My natural way of checking this would be to say int diff = &y - &x;
But this will not work since &y is of type int *** and &x is of type int **. How do I do this?
 
is B() a call to the constructor?
 
it won't work anyway
because they're stack variables and the compiler can do whatever the fuck it wants
 
@FredOverflow that confuses me
 
i.e., the result is UB
 
10:15 PM
Even if the compiler did put them in order, it's not possible to check in some way?
 
@LewsTherin If B is a type, then yes.
 
You can cast both of them to intptr_t, but technically the result of the difference is not meaningful.
 
the result is UB
as in, un-defined behaviour
 
@FredOverflow shit..I meant b.push(Person())
 
@TonyTheLion Are you telling me the most vexing parse is confusing? :)
 
10:16 PM
does it translate to Peson(*)()
 
@LewsTherin Sure, it will call the Person default constructor.
 
right
Makes sense now
 
@LewsTherin What? No. b.push(B()) does not looke like a function declaration.
 
@LewsTherin No, that only happens for the parameter types in a function type/declaration.
 
yeah i have to read about functors... @FredOverflow function call lol
@LucDanton yeah :) so that function declaration if it is in main like I posted...it has local scope
 
10:18 PM
@LewsTherin The most vexing parse is about function declarations that appear to be object definitions. Normal statements like calling member functions can never be mistaken for either of those.
 
@LewsTherin What declaration?
 
@LewsTherin The scope of a function declaration has no special rules. If you declare inside main, it is limited to main.
 
right
 
#include <iostream>
class A
{
    public :
        A(A &a)
        {

        }
        int b;
};
int main()
{
    A c ;
    c.b = 10;
    A a(A ()) ;

}
 
I'm shipping off to university tomorrow
 
10:20 PM
a is local to main and its body must be declared in main to compile
if done that way
 
No, that should compile just fine. You declare the function a but you don't use it.
 
@LewsTherin No, you can define a wherever you want (at top level scope). In fact, you cannot define functions inside main (or inside any other function).
Right, declaring something without ever using is is fine and does not require a definition.
 
@FredOverflow vexing to say the least :P
 
ah cool, but confusing
 
and epically pointless
 
10:22 PM
lol
 
Also, your class A has no default constructor, so even if you fix the declaration of a to A a((A())); you will get a compiler error.
 
scumbag USA
 
@FredOverflow isnt that still a function declaration
 
Didn't the Soviets make it into space first, anyway?
@LewsTherin No, because it is illegal to have parenthesized parameters.
For example, you can't say int square_root((int x));
 
That is a nameless function declaration in itself isn't it...
 
10:25 PM
@LewsTherin No, (int x) is not a legal parameter.
Again, just stop, you're wasting valueable time and brain cells on a stupid corner case of C++ syntax.
 
lol
 
Unless you have nothing better to do at the moment. In that case, keep asking ;)
 
nothing better to do :)
 
same here :)
 
That explains why ha
why is (int x) illegal?
 
10:27 PM
Because it is impossible to generate these parenthesis according to the C++ syntax. No other reason than that.
 
lol, you guys
 
You could just as well ask "Why is f(x int);" illegal?
 
Aw I can see why that is illegal
 
There is no way to put the name first and the type second.
Just look at the grammar of C++ and you will see that you simply cannot generate additional parenthesis around parameters.
 
is it only in function parameters?
doesn't work in the body as well
 
10:29 PM
remember that int(y); is the declaration of y as an int variable
but (int(y)); is the functional-cast of y to int
 
@LewsTherin I don't understand the question.
 
main(){(int x);} doesn't work as well
@JohannesSchaublitb how is it a cast
 
@LewsTherin T(expr) is equivalent to (T)expr, and that's cast notation (as an expression, not a declaration of any kind).
 
@LewsTherin In C++, you can cast either with (T)x or T(x).
But any sane C++ programmer would normally use static_cast<T>(x) and friends.
 
so if you want to do a "no-op cast" you cannot do void(srand(int())); because that would declare a function srand taking a function pointer. either you need to say (void(srand(int()))); or (void) srand(int()); or even void(srand(0));
 
10:32 PM
@LewsTherin Right, because you cannot parenthesize declarations the way you can parenthesize expressions.
 
how is int(y) a variable declaration then if it casts an undefined variable?
 
y is not a declaration, it's okay to parenthesize that :)
 
basically void f(int()); is a function declaration, and if you write something in the parens, it keeps a function declaration but with very different meaning!
 
@FredOverflow no guarantees can be given about any C++ programmers sanity
 
@LewsTherin int(y); is the same as int y; (namely, a variable definition).
int(y); basically says that the expression (y) is of type int, hence y is of type int.
 
10:34 PM
looks like a cast to me...what if y was already defined elsewhere
ah multiple declarations
 
@LewsTherin doesn'T matter
it will be declared and defined another time and be an error if it's in the same block
 
@LewsTherin Then the other y will be shadowed, unless it is defined already in the exact same scope "level". Then you'll get a compiler error.
 
is int(0) ; is that a cast
 
yes, a pretty pointless cast though, because 0 is already an int :)
 
GCC gets it wrong tho
 
10:36 PM
because 0 is a constant/value?
 
Because 0 is not a name.
 
it gives an error for int(x), 0;
 
lol
 
it only takes the int(x) and says to itself "ah all the rest must be declaration!"
 
But in fact it's a cast followed by a NOP?
 
10:37 PM
indeed
 
whats nOp
 
of course, no programmer would ever write such code
@LewsTherin a statement that has no side effect
(NOP = NO OPERATION in assembly languages)
 
@FredOverflow Challenge accepted.
 
remember that also T(x)++; is affected
 
10:38 PM
gcc parses T(x) and errors at the ++
 
ok so why is (int x) illegal :P
can't they write a compiler to make it legal
 
@JohannesSchaublitb It should be the same as T(x++), right?
 
@FredOverflow There you go.
 
@LewsTherin Because C++ compilers must adhere to the C++ standard.
 
ok why does the standard not allow it
i am not trying to be a troll or whatever
3
 
10:39 PM
What would be the point of allowing it?
 
@FredOverflow it should be the same as { T y(x); std::move(y)++; } roughly. except that instead of an xvalue, a prvalue is used as an operand
 
just doesn't make sense to me
 
But if I write T(x)++, doesn't ++ have higher priority? Oh wait, I guess not.
 
you guys are smarter than compilers...impressive
 
10:40 PM
but more recent GCC versions seems to not do this parser error anymore
 
Compilers aren't smart at all, they're just good at following rules.
 
@LewsTherin It's not useful. Why is int,,,,,,,,,,,,,, x also not allowed?
 
hey guys
 
oh good point
 
I'd like to execute int a(!"£$%^&*()(**&&^%$£"!{:@~{:@};'#[)
 
10:42 PM
@LewsTherin If you're serious about the whys of C++, read this book:
 
don't suppose that could be legalized?
 
@DeadMG you must be insane
 
It will answer all your "Why is the syntax like that, why is that feature like that" questions.
 
I bloody hope not
 
10:43 PM
@DeadMG Just feed it to a Perl compiler.
 
@FredOverflow ok thanks..I will definitely read it
 
please stop staring random posts :(
 
lol
 
@JohannesSchaublitb Well, at least we know Lews didn't star those messages :)
 
@FredOverflow just a bunch of references
 
10:45 PM
yeah!
and the starrer apparently doesn't like my posts :(
 
Omg, I just thought of something better to do!
Sleep!
 
@LewsTherin what?
 
Well, at least you see if you like Bjarne's writing style before buying the book. (Which I do.)
 
@FredOverflow they are references to other books or something..
Yep, anyways thanks you freaks :P
 
10:48 PM
The first 6,5 pages are not references. Did you start reading at the end? :)
 
I have a long way to go before becoming one..
 
Don't worry, you'll get there in 3-5 years.
 
@FredOverflow lol I just scrolled down..it is just introduction and stuff
@FredOverflow what? That's a long time...I want to be one Now!
 
Yes, it's chapter 0. What do you expect? Again, it's just so you can deicide if you like the style enough to spend money on the book. After all, it should be fun to read it, right?
 
@LucDanton commented on the altenative solution of the other guy:
3
A: Can I use something like enable_if with an implicit conversion operator?

Kerrek SBHere's a crude hackaround, using conditional rather than enable_if: #include <functional> template <typename T, int N, int M> struct Matrix { struct IncompleteType; T buf[N * M]; operator typename std::conditional<N == 1 && M == 1, T, IncompleteType<T>>::t...

 
10:50 PM
@LewsTherin In that case, may I redirect you to the Java room? ;)
 
lool excellent point
Goodnight man
goodnight all
 
@JohannesSchaublitb Heh, I only considered the declaration (which is valid), not the definition.
 
An implicit conversion operator template sounds scary...
 
i have to force myself not to make another chocolate milk cup
i don't want to get fat
 
You can drink healthy protein shakes and/or work out.
Then you'll get ntfs instead of fat ;)
(NTFS = NeaT & Fucking Sexy)
 
10:55 PM
Allow me to present my alternative: why not have more chocolate milk?
 
Yes.
 
Well, if he's underweight, he should definitely go for more fat.
 
Also, chocolate milk.
 
well, I'm off to beddyboos
 
11:00 PM
What's a good DNS server? Mine's acting up regularly. I did a Google search, but most of the results cannot be displayed, because my DNS doesn't seem to be able to resolve them :)
 
lol
 
OpenDNS is a DNS (Domain Name System) resolution service. OpenDNS extends DNS adding features such as as misspelling correction, phishing protection, and optional content filtering. It provides an ad-supported service "showing relevant ads when we [show] search results" and a paid advertisement-free service. OpenDNS provides the following recursive nameserver addresses for public use, mapped to the nearest operational server location by anycast routing: Services OpenDNS offers DNS resolution for consumers and businesses as an alternative to using their Internet service provider's DNS se...
This seems okay?
Damnit, still doesn't work. Must be something else.
Does this work for anyone here?
Ah, now it works. Must have been some cache issue.
 
11:18 PM
Good night
 
11:56 PM
it says "You have fully used your vote allowance for today" when I want to star another message :)
 
@JohannesSchaublitb oh, yea you have a limited number of stars per day
 

« first day (357 days earlier)      last day (4607 days later) »