« first day (799 days earlier)      last day (4374 days later) » 

10:17
It will be become boring after it's been revealed.
Anyone saw the Code Golf where you have to print numbers from 1 to 1000 without using semicolons anywhere in your program?
I think it's fun :)
Xeo
Xeo
Meh, not using semicolons means you're basically fucked with any C-derived language, IMHO.
This guy found it: #define Please(x) if (x) {}
Please(std::cout << " " << x)
lol
He didn't get many upvotes :D
Xeo
Xeo
That's not golfed, really.
I would try something like if (system("seq 1 1000")){}
Not portable though.
Linux is all you need ;^)
10:29
@StackedCrooked Where is link to that codegolf?
I think I never really understood the purpose of constexpr
especially when used in a function definition like constexpr int foo() { } type thing
20
Q: Print 1 to 1000 in C++ without semi-colons

marcogFollowing this popular question, present your solution which prints the numbers 1 to 1000 (all of them, not the string "1 to 1000" verbatim or something funny) in C++ without using any semi-colons. Unlike the original question, you may use conditionals and loops. Solutions not requiring any comp...

2
Thanks
@TonyTheLion The number of C++ experts was getting too high.
10:31
^ Post to fake interview that makes such a claim.
Xeo
Xeo
@StackedCrooked Holy crap, just how many answers there are actually writing C?!
so does stacked-crooked.com's compiler not support constexpr then?
I don't feel like counting them, sorry :P
@TonyTheLion Yeah, I suck at compiler writing.
It's the truth!
10:36
what version of GCC is it?
Xeo
Xeo
4.7.2
lim loc( OOP -> FP ) = 0
my git commits are getting smaller every time
Dang.
407 is easy but it's an optimisation problem.. ;_;
My weakness ;-;
What the hell are you talking about?
I can't optimise for shit.
So it runs slow.
10:42
static_assert(x > 5, "You fail"); so why can you not do this when x is int ?
needs to be determined by compile time
Xeo
Xeo
@TonyTheLion not a compile-time constant?
hmmm
so x would have to have a value at compile time
@Rapptz Show code and I'll throw you a hand
@TonyTheLion Or a range of values if you using q++ compiler.
10:46
hmmmm
That was a quantum joke.
so I guess you can't use static_assert for checking value ranges of arguments then?
but wtf is the point of this thing then...
man I feel stupid!
@TonyTheLion compile time checks, type traits etc
Xeo
Xeo
@TonyTheLion What's so complicated with static assertion?:P
template<int N>
struct matrix {
  static_assert(N > 0, "minimum limit");
  static_assert(N < 100, "maximum limit");
};
^shitty example
10:49
I'm just confused, I've never really used static_assert and never really bothered to look at how I could use it
Xeo
Xeo
You only need it in conjunction with templates, really.
ah right
but you can use it with constexpr functions?
Xeo
Xeo
Not inside of them unless they're templates.
Since the parameters of constexpr functions aren't considered constant expressions.
Hm, is it possible to assert inside a constexpr function?
10:54
> If a constexpr function or constructor is called with arguments which aren't constant expressions, the call behaves as if the function were not constexpr, and the resulting value is not a constant expression. Likewise, if the expression in the return statement of a constexpr function does not evaluate to a constant expression for a particular invocation, the result is not a constant expression.
Xeo
Xeo
Your header file should usually not contain code, unless it is the code of static inline functions or of template functions. And you should compile with g++ -Wall -g. And intuitively, header files are "smaller" (since they should contain more declarations than definitions) than source files. — Basile Starynkevitch 1 min ago
> #include "Algorithm.cpp"
Xeo
Xeo
@Pubby With comma operator I think.
heh
Xeo
Xeo
Btw, there is a way to get a static assertion for compile-time arguments to a constexpr function.
10:55
@Xeo But the assert function isn't constexpr AFAIK
Xeo
Xeo
@Pubby So?
Also, why static inline instead of just inline?
@Xeo You can't call non-constexpr functions in constexpr ones
Xeo
Xeo
Only one evaluation path inside a constexpr function needs to be a constant expression.
Sure can.
Hm, okay
Xeo
Xeo
It's only an error if there are no arguments with which a constexpr function would become a constant expression.
for example
constexpr int stuff(bool b){
  return b? 42 : throw "nope";
}
is a perfectly fine constexpr function
10:58
I don't think I like constexpr very much. Normal functions and TMP are nicer
yeah I prefer TMP myself
they are neither black nor white, they are grey
Xeo
Xeo
Aye, it may seem a bit silly.
The only time it is probably worth using is when the compile-time version would be implemented in the exact same way as the run-time version, which is very very rare
Xeo
Xeo
Not really.
It's perfectly fine to write one when you only need compile-time computations.
E.g. as arguments to a non-type template parameter.
11:00
I suppose so
Xeo
Xeo
Anyways, time to walk the dog.
Have fun.
@Pubby are static free functions actually possible?
@bamboon static means internal linkage in that context.
@bamboon Function object.
11:06
@StackedCrooked ?
I might have misunderstood your use of the word static.
@Ell a decent amount of C++11. And Boost.Assign for MSVC2012 cause it's missing braced init lists.
hi all, who can help me with MFC please?
i'm trying to build an MFC application that displays the full path of a directory that is selected in a ShellTreeCtrl
@StackedCrooked I was referring to the comment which claimed that functions in header files should be static inline and I was wondering if static free functions are possible at all.
@Androidy you should use something decent like Qt or WTL instead of MFC.
11:11
i wish i had a choice!
@Androidy Also use lisp :p
i have a code the shows me the name of the selected item but not of the full path.
is there another channel for MFC ?
Sorry, I have absolutely no clue about any proprietary MS libs :/
wakarimasen
@bamboon - yes, static inline in that context means not visible outside of the scope of the unit/.cpp file that includes it (internal linkage as Pubby stated) and inline so you don't get a multiple-definition linkage error should that header file be included by more than one .cpp (since you are embedding it inside the header rather than have the implementation in a .cpp, as in the usual case)
11:18
@kfmfe04 just static is enough for that
static free functions have existed since C
@kfmfe04 yeah, thanks. I knew about the inline stuff but the 10000 use-cases of static confuse me regularly
static is one of the most overloaded keywords in the language.
Xeo
Xeo
It's going to be even more overloaded with static if :)
11:29
is there going to be a static if?
Xeo
Xeo
Aye, concepts-light
huh. Should just let the compiler figure out the static...
@Xeo if at class scope is obviously supposed to be static
Disclaimer: I have no idea what concepts are (I know what they represent, just not how and when they are useful/used, etc.). Don't bother educating me right now. I'll be gone in a minute :p
Xeo
Xeo
11:35
@rubenvb template<class T> void foo(T const& v) if(has_special_trait<T>::value) { ... }
There, less than a minute. :D
Basically a really concise form of SFINAE
@rubenvb There are two different proposals for static if, which I think were planned to be merged or something. I'm pretty sure we'll get static if.
IMHO there's no real reason for a seperate static if in that case...
Xeo
Xeo
There is.
it's a constexpr condition, so the compiler can optimize the stuff out.
Xeo
Xeo
It's not about optimization
11:37
@Pubby I always forget one can overload the comma operator. Which is probably a good thing :)
Xeo
Xeo
Note where the if is placed.
It's before the function definition begins with the opening {
It's about problems that can occur when using tempaltes.
you can already put a try there as well IIANM (at least for main I'm sure). No reason an if would be more out of place.
For example you need the template parameter to be both dereferencable and incrementable (e.g input iterator)
Xeo
Xeo
template<class T> void foo(T const& v){
  static if(has_some_fun<T>::value){
    auto u = v.some_fun();
  }else{
    auto u = ...;
  }
  bar(u);
}
11:38
you might as well do that inside the function...
Xeo
Xeo
This one is inside the function.
That's why it needs the static.
@Xeo Oh, throw is an expression, not a statement? Then I can write throw "kthxbye", "You'll never get here"? Cool :)
Xeo
Xeo
And you can't use normal if.
I still don't see a compelling reason for a non-normal (albeit extended in functionality) if
Xeo
Xeo
Since v.some_fun() will be ill-formed if T doesn't have some_fun.
The compiler has to parse and check unevaluated code for normal if.
11:40
then change that parse requirement if the condition is constexpr
why not just say the if the condition is consexpr then the block wont be check for well formed-ness
Xeo
Xeo
Also, names inside the braces of static if are not inside their own scope.
Xeo
Xeo
See my example above again.
Note how I use u outside of the static if ... else
hmm
working around a language limitation by adding a feature. Lovely.
Xeo
Xeo
11:41
template<class T>
struct X{
  static if(has_trait<T>::value){
    something special;
  }
};
@Xeo Is ... a valid expression? Or did you mean ...? :)
Xeo
Xeo
@FredOverflow shaddup
if all conditional branches introduce a variable, it should be possible to do what you did with normal if IMHO, but C++ thinks otherwise.
I like how Andrei distinguishes between ... and ... :)
Xeo
Xeo
@FredOverflow da-da-da
@rubenvb It's a completely different functionality, so it should be a new construct.
11:44
@Xeo bah, I still would like to see a more lenient normal if: if(bla()) auto t = something(); else auto t = something_else(); do_something(t); should be possible.
@FredOverflow what? enlighten me please.
Xeo
Xeo
Why? What if you do not want that behaviour?
@bamboon Watch his GoingNative2012 talk
(Variadic templates are funadic)
@bamboon ... is the C++ construct ("ellipsis"), while ... is not real code, but a placeholder for something else.
@Xeo is that directed to me?
anyways
I'm outta here
Merry Christmas everybody!
@rubenvb Where is that Bjarne Christmas gif?
11:52
@FredOverflow It's from my profile page
Stupid sexy Stroustrup.
2
no GIF of Andrew Koenig?
@Cheersandhth.-Alf I can make one
@Pubby i'll post it to andrew's facebook page
:)
he he
11:59
@FredOverflow I believe Andrei uses ... and … (&hellip; // U+2026) :P
@Cheersandhth.-Alf how about Walter Koenig?
Ho ho ho, I made this for you:
please thanks but no animated gifs in chat
As a side note, the parameters to a function being called are also following the same rule: left to right. However, Visual C++ (cl) compiles right to left in debug mode. Something to keep in mind. Although it is somewhat different from the command operator per se. — Alexis Wilke 19 mins ago
lol @ evaluation order and "command operator"
Don't flag gifs
Buy a better computer
12:07
1 message moved to bin
or just bin them
@Rapptz Still working on 407?
@DeadMG well it's bin a while since i had that possibility
Cat could have done it, though
I don't care
GET OVER GIFS ALREADY GEEZ
@rubenvb How about auto t = blah() ? something() : something_else();? Or do they have different types? lol
12:13
@Cheersandhth.-Alf Andy gif
2
(oh god, what have I done?)
what is the problem with gif's other than taking space?
They distract.
from what? :p
are you saying chat is not entertaining enough?
he he
what does joycux mean?
Makes the chat look like Facebook :)
@Cheersandhth.-Alf typo?
12:15
It already looks like reddit at times, can't get much worse
@melak47 I wasn't sure, so I deliberately left that part out :)
@Cheersandhth.-Alf It's "joyeux".
Joyeux Noel merry xmas in French
@JohanLarsson Yeah, the real world is "joycox".
Joycocks
i'm not sure i dare post that to andrew's fb page...
<g>
12:19
@Pubby did you make that just now? mad skills if so
@JohanLarsson I used this shitty site: blingee.com
@Pubby they have strippers & blunts in stock?
Chat crashed, that was wierd
@JohanLarsson Yep, along deer and dancing cats.
It is like if the 90s was made in web 2.0
12:38
@Pubby is there a way to control z-index?
@JohanLarsson Dunno, sorry
12:58
If you're new and don't want to be hated.. I love the welcoming tone in this one.
I'm reading text from file. I can not read the whole file at once, it might be very big. Is it better practise to keep my file opened or to close and open it dozens of times?
You can't contain the entire file in RAM memory?
Random Access Memory memory? Memory that memorizes memory? whee my head is spinning
2
The first. Just plain old ram.
that sure is some big text file though
13:04
Probably I can, but that's not a point. I'm writting something like linux "less" command and reading the entire file at once is just... wrong. It might cause my program to slow down and consume lots of RAM
If you close the file and later reopen it then it might have changed. So your offset value would be wrong.
So I suspect that you will need to keep the file locked for the entire operation.
You've got a point. Ok, I'll keep my file open. Thanks!
Alright!
And remember to use RAII.
13:23
anyway, it's c++hristmast toomorrow
I feel weird for not being at home yet.
Don't substitute numbers for words
@CatPlusPlus Don't you mean, "Don't substitute numbers 4 words"?
3
@FredOverflow sure, different types. Enough cases where overloads and virtual functions can make such a thing useful.
Constexpr makes it compile-time and no problem for compiler writers.
Don't substitute stuff for language
FTFY
@BartekBanachewicz mast?
13:40
IIRC the expression (a ? 1 : 0) is like a constexpr in that it can return a compile-time constant or not depending on the input. Right?
That's not a great way to phrase it. To wit, 'a constexpr'.
Good thing I don't write standards.
But yes, constant expressions may involve the conditional operator.
is there anything you can do with if ... else ... that you can't do with ?:?
Write understandable code.
13:46
@rubenvb what is iths ?:? operator :p
@rubenvb You can omit the else branch.
@melak47 the last question mark is punctuation.
@rubenvb really ._.
@rubenvb cpt obvious
To the rescue!
I'll be here most of the week!
13:49
Sometimes you must use ?:, for example to define a reference.
@StackedCrooked Testing says the answer is yes (MSVC).
13:59
Make if-else an expression, problem solved
No
1 message moved to bin
Also what a terrible website
Sorry, chat doesn't like unrelated link posting.
(don't post it again or you'll probably get banned)
It's ok. And sorry again.
@Pubby AFAIR, banning is nigh to impossible here
14:02
It only takes coordinated flagging
(People are still bad at it)
Plonking is the closest you can get to a real ban.
Banning only lasts an hour anyways
It's enough to get rid of most people
Those few special snowflakes we just flag multiple times
Don't flag stuff in bin, pointless.
Ban is global, doesn't matter where posts are
14:05
lol
I'd prefer local /ban but oh well
SO insists on keeping owner function useless
@leftaroundabout With the built-in comma operator (i.e. no user-defined overloads), both (a, b), c and a, (b, c) will evaluate a, b and c (in that order) and yield the result of c. How is that not equivalent? — FredOverflow 34 secs ago
@FredOverflow So?
Just checking my sanity here:
Why would they be equivalent? Not even (a + b) + c and a + (b + c) are guaranteed to be equivalent. (They aren't in floating-point arithmetic for accuracy reasons, and in some exotic number systems they aren't even supposed to). — leftaroundabout 2 hours ago
I don't see how , relates to + or other operators.
14:10
It's an operator like any other
I don't see why it would be special
@FredOverflow They are both associative
All operators are associative
:v
@CatPlusPlus not - and /
(screw that term, it should be called "dual-associative" or something rather than just "associative")
wut?
Parsing term, not math term
14:11
Let me restate the question: Can you write a program where a, (b, c) behaves differently from (a, b), c without overloading operator,?
associative is a well-defined mathematical concept.
the meaning of parentheses depends on language syntax.
@FredOverflow I still have no idea why are you asking this
so the parenthesis might even be a function call for all we know in Hell++ (anonymous functions ftw!)
@CatPlusPlus Well, in parsing terms stuff like == isn't associative (non-associative)
@CatPlusPlus Because leftaroundabout says that they are different, and I don't see how.
14:13
@FredOverflow would int* (a,b),c qualify?
I'm not sure that it's even allowed.
@rubenvb lol
== is technically left-associative
@FredOverflow What
I just don't get what's the fucking premise here
, is operator like +
They decided it'll be left-associative, so what
It makes sense if the original semantic is sequencing of operations
>>= is left-associative too
@CatPlusPlus I say that sequencing of operations would work exactly the same if it was right-associative.
Maybe. So what
14:16
@StackedCrooked That does not sound like a good use for anything.
@StackedCrooked WTF is the point of that?
If you have five things to evaluate, do you evaluate the first thing first, and the remaining four after that? Or do you evaluate the first four things first, and the last thing after that? I think it does not matter.
If they made it right-assoc, you'd be asking why it's not left-assoc or what
I believe it does not matter, and I want to know if I am wrong.
14:16
I would think my example still stands though.
Never mind then.
It doesn't matter if the semantics are math-associative
@StackedCrooked What were you trying to do?
Precalcuate the results at compile-time for common cases.
But it'd be either left- or right-associative anyway
14:18
@StackedCrooked 0 is already a constant expression, there's no reason to use that constexpr function
@StackedCrooked Just make your function constexpr as well, and return the other.
@R.MartinhoFernandes The inputs are received at run-time.
Ah, wait.
That's in fact a motivation for constexpr functions, hence the advice.
14:23
Napland sounds like a place of wonder.
Imma make a trip to Snack Sector right now.
14:36
I'm annexing this nation
What, today?
14:51
folks
@FredOverflow Elements of Programming chapter 3 is about associativity. (It illustrates how its properties can be used to implement the power function efficiently.)
And other things.
Just FYI. Not sure if relevant to your question.

« first day (799 days earlier)      last day (4374 days later) »