« first day (415 days earlier)      last day (4531 days later) » 

7:00 PM
What's Toledo? (Other than a Spanish city)
 
The concept of the Iron Curtain symbolized the ideological fighting and physical boundary dividing Europe into two separate areas from the end of World War II in 1945 until the end of the Cold War in 1989. On either side of the Iron Curtain, states developed their own international economic and military alliances: * The Council for Mutual Economic Assistance and the military Warsaw Pact on the east side, with the Soviet Union as the most important member of each * The European Community and the North Atlantic Treaty Organization on the west and south. Physically, the Iron Curtain took ...
I totally didn't get that the Iron Curtain was for more than Germany Berlin
 
it's a kind of BlackBoard. I can't really seem to find the website :/
 
@Xaade It was the whole fucking thing, from the Northern Sea to the Mediterranean.
Kinda hard to believe.
@rubenvb Oh. BlackBoard sucks.
 
@rubenvb ugghhhh.... Blackboard exists only because someone who makes good stuff, never bothered making anything for public schools to use.
 
why my code is not working, It is to detect whether a type is class or not ? : ideone.com/UlgwM
 
7:02 PM
Blackboard was the most PITA-POS that I've ever dealt with. Especially for students.
 
@FreakEnum You don't need to define the functions, btw.
 
Our uni now has three different systems: BlackBoard. SiSa selfservice, and their website on which you can log in on various subpages and access things like software serial keys.
SiSa is like a webshop for your courses. I had to "check out" my program
 
@RMartinhoFernandes yes but I'm learning SFINAE, so need to :)
 
which is kinda messed up terminology
 
@FreakEnum Should be static functions too.
@FreakEnum No, you don't need to define them (the test functions I mean).
You only use them in the sizeof.
A declaration is enough.
 
7:04 PM
@RMartinhoFernandes aah , It doesn't evaluates the expression , right?
 
I love how Blackboard (at least in the incarnation I had used), made user feature access mechanical. You could only visit certain pages. It was a different website altogether depending on the user type. Which made it really hard because teacher's didn't know how to tell their students how to navigate to pages they never see.
 
@RMartinhoFernandes but why the function needs to be static (it's working now)
 
@FreakEnum Because otherwise you can't call them without an instance of the class!
 
that's a bit of a non-answer. You can't call a function without defining it either, and you just said a definition isn't necessary ;)
 
7:06 PM
Shush.
@jalf You can call it on a non-evaluated context.
 
@RMartinhoFernandes but you see I'm just seeing the value of enumrator yes not function
 
But you need a "non-evaluated instance".
 
@RMartinhoFernandes didn't get :|
 
@FreakEnum class a { void f(); }; // can I call f() out here?
 
@RMartinhoFernandes no
 
7:08 PM
Oops.
struct a { void f(); }; // can I call f() out here?
 
@RMartinhoFernandes no, until it's static
 
And in your case it's the same thing.
An enumerator is a compile-time constant. There is only one, not one per instance.
 
@RMartinhoFernandes It's funny, they can build a wall from those two points, but we can't build a wall south of texas. I guess West Europe wasn't getting liberal votes from Russia.
 
@RMartinhoFernandes aah, now got it , Thanks :)
 
I'm taking a nap. See you later.
 
7:20 PM
I'm wondering why a file opening mode is always passed to the function, that open a file, why not rw by default? Is this for security reasons?
 
If I had to guess, because locking.
If it'd always be read-write, then you couldn't have shared locks (shared reads, exclusive write).
 
@CatPlusPlus thanks
 
(Or the implementation would be much more complex, checking every operation instead of just opening.)
 
cpx
@Beginner I think in teh C++ read/write is default when you open a file.
 
7:35 PM
Depends on what stream class you're using.
But you still can override it.
 
@RMartinhoFernandes when I was at a huge bookstore the other day, there were like 200 C# books, and about half a dozen C++ books....including "teach yourself c++ in 10 minutes". I was sad.
 
do static's in lambda's work like static's in functions? Is the state carried through forever? Or is the lambda "instantiated" each time the function it is used in is called?
 
it turns into a function object...so I'd say yes to all three???
 
@keithlayne so consecutive calls to the function where the lambda is used would retain the static's value? It would only be initialized once?
I'm going to ask this as a proper question
 
7:50 PM
I don't know, it seems like it would be easy enough to check
 
it's too new a feature to trust GCC or MSVC IMHO
 
My point is that if you have a function object and use it say in a STL algorithm, you would create a new instance usually...but function static data should remain over all instances of a regular function obj, right?
 
but a "normal" function object is global, really, not local.
 
isn't a lambda just syntactic sugar for a "normal" function object?
I guess capturing might make a difference, I don't know how that's specified.
 
It would be weird capturing would change the behavior of static's
0
Q: static variables in lambda function objects

rubenvbAre static variables used in a lambda retained across calls of the function wherein the lambda is used? Or is the function object "created" again each function call? Useless Example: #include <iostream> using std::cout; void some_function() { vector<int> v = {0,1,2,3,4,5}; ...

 
7:59 PM
The compound statement is the body of operator() of the closure type.
So they'll be preserved through calls to the same closure object.
 
frankly, that sucks
 
evening
 
TBH I don't really know the behaviour of static in member functions.
It's not useful at all.
 
what's the best way to convert char* to std::string?
 
copy construct?
 
8:03 PM
std::string(foo)
 
would std::string(std::move(foo)) work with char*?
 
I doubt it, really.
 
@keithlayne It would work. It wouldn't do anything useful.
as compared to std::string(foo)
 
GCC disregards that static altogether.
 
Come on, a comment with 3 comment-upvotes, and only 2 question upvotes :(
 
8:07 PM
@rubenvb Why would you need that, anyway?
 
for example, probably highy inefficient:
 
If you need complex state, capture a variable or write a proper functor.
 
for_each( list.begin(), list.end(),
          [](const string& item)
{
    static size_t i=0;
    list[i++] = item;
}
something like that.
 
And that's useful for what?
You can't get it out of the lambda, anyway.
Oh wait, sorry.
 
hold on, not a good example
that's just useless
 
8:09 PM
I'm misreading. Anyway, back_inserter does that.
 
not if the assignment is more complicated
it was a stupid example, hold on
 
You can always take it out of the lambda, and capture it by reference.
 
Try this:
typedef pair<string, time_t> file;

for_each( list.begin(), list.end(),
[this](const file& item)
{
static size_t i=0;
m_list[i++] = file.first;
}
and m_list is a vector<string>, list is a vector<file>
contrived yes, I warned you :)
 
m_list.push_back.
 
@CatPlusPlus I'd like to preallocate (theoretically, I know contrived)
I'm sure there's more general examples one could think of
 
8:12 PM
Then auto dest = m_list.begin(); for_each(list.begin(), list.end(), [&](const file& item) { *dest++ = file.first; });
 
transform(list.begin(), list.end(), m_list.begin(), [&](const file& item) { return item.first; });
 
yeah, ok, my coding sucks. I still think it's an interesting question in retrospect :)
<snip snip code>
 
Function-level static is mostly useless.
 
@CatPlusPlus not if you're storing a runtime value that needs quite a lot of calculation.
then it's a godsend
 
It never needs a static.
If it needs a static, then your design is wrong.
 
8:15 PM
it is handy though
 
Statics are globals hidden within functions.
 
that are initialized on the first call to the function
which is why it's handy, IMHO
 
If you need state, then you need a class.
Now that someone mentioned you've missed ++ in that code, call count goes up to 11 on GCC.
I've never used a static in a member function, I guess that's how they work.
 
@CatPlusPlus Shouldn't we use static for const variables inside a function ?
 
No, why?
 
8:22 PM
@CatPlusPlus for example, if the function needs some expensive runtime resource or thread-local memory that's expensive to allocate, a static is really handy.
 
static in multi-threading are bugs. They're nigh impossible to sync.
 
true, you could mutex it easily though
 
static and thread_local don't really co-exist
 
I'm good at inventing bad examples
 
Function-level static should be removed, really.
 
8:24 PM
eh, I don't think it's that bad
better than class-level static
 
@KerrekSB: check the edit details to see the removed whitespace ;-)
 
`bool not_url_char(char c)
{
// characters, in addition to alphanumerics, that can appear in a URL
static const string url_ch = "~;/?:@=&$-_.+!*'(),";
// see whether c can appear in a URL and return the negative
return !(isalnum(c) ||
find(url_ch.begin(), url_ch.end(), c) != url_ch.end());
}`
 
@rubenvb You mean for the abusing line?
 
static doesn't buy you anything.
 
@CatPlusPlus Of course not, only money can do that, and only if you do it yourself, as money is quite immobile...
 
8:27 PM
@rubenvb Ahh. Ohh. Yes, because, the whole thing would have moved over even further with the std, so I thought in the interest of readability I prune a bit of the whitespace. Hope that's OK?!
 
@KerrekSB it was a joke, relax :p
 
@rubenvb Now I'm thinking that the using line should go inside the lambda... though everything inside me wants to kill it entirely
 
@CatPlusPlus Ok. Will keep that in mind.
 
My therapist says genocide is an acceptable response to namespace std.
 
@KerrekSB understandable. I did warn you with "Useless example". It does nicely present the question asked though. After my first-minute edit :)
 
8:30 PM
There's no good excuse for abusing namespaces.
 
@KerrekSB and thanks for the fixup btw :)
Woop woop 7 upvotes and counting :)
 
@rubenvb I just realized this question isn't about lambdas at all
-1! :-)
 
@KerrekSB how so?
 
See my comment.
You can ask the same for any nested class
 
is there such a thing as a nested class?
 
8:34 PM
void zoo()
{
    struct Boo { void operator()() { static int c = 0; std::cout << "Boo: " << c++ << "\n"; } } boo;
    boo();
}

void main() { zoo(); zoo(); zoo(); }
 
I though those were illegal?
an extension at most
@KerrekSB Your zoo is scary
 
@rubenvb I'm tired of foo
 
Use bar.
 
Imagine you're in a haunted house, and a ghost flies up to your bed and goes, foo().
 
where did foo bar come from anyway? It sets a bad naming example
 
8:36 PM
You wouldn't be scared. You'd just ask, what's *this?
 
Xeo
@KerrekSB I thought local classes are not allowed to have static members?
 
@rubenvb Depends how old you are.
 
Xeo
Or was it non-static members?
 
They're meta-syntactic variables, they're not examples of naming.
 
@Xeo Is that true? Then surely the same must apply to closure types
 
8:37 PM
@CatPlusPlus : but Kerrek just used static.
 
@rubenvb nested class == legal, nested function == gcc extension
 
@vivek Because they're talking about static?
 
@rubenvb you familiar with FUBAR?
 
@keithlayne wow, didn't know that.
@keithlayne You mean "Fucked Up Beyond All Recognition"?
 
I was gently informed about the nested functions here, I had misread somewhere
 
8:38 PM
Are you talking about my example code by any chance?
 
@CatPlusPlus how would you preserve a value between function calls ?
 
yeah, that's where I always assumed foo and bar originated from
 
If you need state, you need a class.
 
oh
 
It's "Fucked Up Beyond Any Repair".
 
8:39 PM
@CatPlusPlus You come over as ... old. You keep repeating yourself :p
 
@CatPlusPlus I thought I was the only one who needed to repeat myself to be heard
 
It's a lot of things Fucked Up:
http://nl.wikipedia.org/wiki/FUBAR
 
@Xeo Do you have a reference for that?
 
@CatPlusPlus by the way, you can't edit american idioms on a whim...we own them
 
Xeo
@KerrekSB Gimme a sec
 
8:41 PM
@keithlayne I couldn't care less.
 
seems only the Dutch wiki site lists all variants :)
and mine wasn't listed
 
Yours didn't even have A in it.
 
@CatPlusPlus I was just playing...don't kill me
 
@CatPlusPlus I fixed that.
 
Xeo
@KerrekSB §9.8 p4 "A local class shall not have static data members."
 
8:43 PM
@keithlayne I was referencing "I could care less" that some silly Americans like to spread. :P
 
@Xeo good find
 
Well, then, now we have a lambda with a static variable in the function body. This question gets better and better the longer you guys talk about it :)
 
@CatPlusPlus stupid americans
 
>2011
>still coding in C++
 
@CatPlusPlus do you know the american stereotype about people of Polish descent?
 
8:47 PM
@KerrekSB : Why was your answer regarding static locals nonsense? It seemed reasonable
 
Not really.
@lezebulon: 4chan's the other way.
 
@CatPlusPlus if you came to the states, the sky might fall
 
Well, I don't intend to.
 
@KerrekSB : Oh, nevermind. It would have been a function-local static, not a static data member. :-P
 
@Xeo I had that too, but that's not function-local
 
8:51 PM
void MyFunction() {
    struct helper {
        static bool is_even(int i) { return i%2 == 0; }
    };
    // use helper::is_even as a functor in std algorithm
}
^ Is this legal in C++03? Someone told me it is not and that the only reason it works for me is because my compiler is non-compliant.
 
@ildjarn Yes, quite
@ildjarn Because it's not clear whether local static variables are "static members"
 
Xeo
@StackedCrooked Should be legal
 
@StackedCrooked I think you can't use this type as template argument.
 
Xeo
It's just that before C++11 you couldn't use local types as template arguments
@KerrekSB What do you mean?
 
@Xeo Well, he's asking for 03. :P
 
Xeo
8:52 PM
What I posted was only concerning static data members of local classes
 
@Xeo A static data member refers to a class member, non?
 
Xeo
@CatPlusPlus Erm.. right, nvm me
@KerrekSB Yes
 
But we are talking about local static variables in a member function
 
Xeo
Were we?
 
I have no idea what the status of the latter is.
Yes, see my Zoo example
 
Xeo
8:53 PM
Ooooh, yes, we were
ooops
 
Same as the lambda expression in question
 
Xeo
Then I misread that boo class :s
 
@Xeo: You need more tea. Well, or, ugh, coffee, I guess.
 
Xeo
Ugh, coffee..
 
I just had free coffee...it tastes better when it's free
 
user457812
8:57 PM
Hm, coffee... I should drink some. Doing two presentations in one day has left me tired.
 
@nil when is the semester over?
 
user457812
I'm not sure, some time next week
 
I drink distilled badassery and piss pure excellence
3
 
user457812
So does that mean there's no actual excellence in you?
 
yeah, I'm currently on E
 

« first day (415 days earlier)      last day (4531 days later) »