« first day (737 days earlier)      last day (4203 days later) » 

4:00 PM
@Cheersandhth.-Alf That makes no sense to me.
 
Times Java was mentioned in the OP: 0
 
room topic changed to Lounge<C++>: For the sake of arguing... [c++] [c++11] [c++-faq]
 
Concatenating two strings in Java consists of allocating space for the result, and copying everything in.
That's O(N), with N being the sum of the sizes.
 
@R.MartinhoFernandes the Java language specification can't put a limit on the complexity of += string concatenation because it can't optimize it, because it can't guarantee a single reference to the buffer, which must appear immutable to the programmer
in contrast, in CPython only a single thread is accessing the thing at a time
 
Java relevancy to anything: 0
 
4:02 PM
@CatPlusPlus I've applied for the dev group :) I'm new to this bitbucket thing...where is the actual repo with the project? :S
 
Optimize what?
Copying M+N characters into a new buffer?
 
@cat: i am not sure, but C++ has recently moved from single-threaded (like CPython at lower levels) to multi-threaded (like java)
 
@Cheersandhth.-Alf Why do you keep mentionning Java if Java is not mentionned even once in the question and is not even in the tags?
 
It's hidden. We haven't sorted out this thing yet. cc @thecoshman
 
@R.MartinhoFernandes reusing the buffer and appending, instead of copying. u now
 
4:02 PM
@CatPlusPlus Times Java was insulted in this room: 7838
 
@EtiennedeMartel Because he knows the OP is interested in Java, despite not mentioning it.
 
Because std::string::operator+ is like Java's immutable + duh
 
i have a constructor LexicaAnalyzer::LexicalAnalyzer(std::string&), and I'm trying to instantiate this class this way

LexicalAnalyzer lexicalAnalyzer(indata);

But it keeps saying "expected primary-expression before 'lexicalAnalyzer'"
also expected ';' before 'lexicalAnalyzer'

any idea?
 
@R.MartinhoFernandes And he's the one who bashed on @kbok for "using ESP" or something?
 
It probably expects primary expression before lexicalAnalyzer
 
4:03 PM
Yes, he was.
 
I bet LexicalAnalizer is not in scope.
 
@rogcg show all the code
 
For me ESP is the extended stack pointer.
 
+1 ^
 
4:04 PM
@EtiennedeMartel java is relevant because it is an example of the third set of design choices for this operation, greatly affecting the guaranteed efficiency
that should not be so hard to understand
 
There's nothing wrong with using ESP.
Actually it would be quite silly not to use it.
 
@Cheersandhth.-Alf The guy asked how to concatenated strings in C++.
 
Relevancy of efficiency to the OP: 0
 
it is purely technical, nothing to do with ESP or guessing the OP's interest beyond the interest in string concatenation
 
You cannot assume anything that wasn't written.
 
4:05 PM
It is not technical, it is something you want to talk about badly but nobody cares
Including the OP
Who is a bad poster
 
@EtiennedeMartel try to start thinking? yes that was the question. what possible connection could there be between a question about string concatenation, and string concatenation?
 
main.cpp -> http://paste.ubuntu.com/1297829/
LexicalAnalyzer.cpp -> http://paste.ubuntu.com/1297831/
 
See, nobody thinks around here.
 
So we're still on that topic. Brilliant.
 
4:05 PM
You'll probably use the stack pointer while concatenating strings.
 
This is beyond ridiculous.
 
@CatPlusPlus you're saying that because you realize that you helped to wrongfully delete a question
 
@rogcg dude, srsly, Stack Overflow
 
Yup, I did
 
And that's terrible.
 
4:06 PM
I'm very proud of it
 
@rogcg indata is not string.
 
Gotta keep that kill count high
 
@Abyx no it's ifstream. where are u seeing string?
 
it's not healthy
 
Headshot questions erry day
 
4:07 PM
it's not how moderation should work
one should not delete things that one disagrees with
it's is weak
to do so
 
> Why do you look at the speck of sawdust in your brother's eye and pay no attention to the plank in your own eye?
 
@rogcg and your fucking ctor expects string.
 
I don't disagree with string concatenation
 
Okay this is just boring now. I'll be back tonight and see if you're still stuck on that existential question.
 
Anyway, TIL that for some reason Java optimizes string concatenation to O(N^2).
Now I need to make a phone call.
 
4:07 PM
@Cicada We'll be stuck on it as long as Alf is here.
 
"optimizes" :))
 
Java is retarded, but we knew that already
 
knock knock
 
@CatPlusPlus you certainly disagreed with the question :-)
 
You know what's weak? weak_ptr.
 
4:08 PM
@Abyx are u mad?? it expects std::ifstream&
 
This room is a trainwreck today
2
I'm going to bed, see ya
 
@rogcg you wrote i have a constructor LexicaAnalyzer::LexicalAnalyzer(std::string&) before
 
@Abyx ohhhh I misstypedd.. I thought you were following the code I gave you!
 
@CatPlusPlus it may get better. IMHO it needs a bit more wrecking. too much socializing and group mind here lately, i.e. too much conformity
 
Hint: if argument is of the wrong type, the error is different
 
4:10 PM
i think a main thing is to not let people get away with technical incorrectness
 
@rogcg meh... code. Write a SSCCE... (see sscce.org)
 
no matter social position or how many others are proven "wrong"
 
Too much socialising in a social place called chat room yeah that makes sense
 
then when everybody knows that it's best to be truthful, things can get better again
 
4:11 PM
@Abyx why meh.. code?
 
I even have a way of ensuring that
 
@rogcg b'coz it's meh.
 
if I have constructor Class::Class(std::stuff&), and if I instantiate it like Class myClass(stuff), it should work!!! AGHHH
 
nevermind, just go ask on SO
 
@rogcg not if stuff is const or volatile.
 
4:14 PM
@daknøk its not a const or volatile.
 
REally, why do you write empty destructors all over?
You get an empty destructor for free every time.
 
@R.MartinhoFernandes I'm gonna implement it later. It's just not implemented yet. jut for me not to forget.
 
That sounds wrong.
Somehow.
 
"You ain't gonna need it" or “You aren′t gonna need it” (acronym: YAGNI) is the principle in extreme programming that programmers should not add functionality until it is necessary. Ron Jeffries writes, "Always implement things when you actually need them, never when you just foresee that you need them." Rationale According to those who advocate the YAGNI approach, the temptation to write code that is not necessary at the moment, but might be in the future, has the following disadvantages: * The time spent is taken from adding, testing or improving necessary functionality. * The new fe...
 
@R.MartinhoFernandes why?? it's just a remembering
hahaha
 
4:17 PM
Because you should not be implementing destructors in without implementing or forbidding copy constructors.
 
@R.MartinhoFernandes I'm still building the classes, as you can see there is a bunch of errors, I have to fix the instantiation of the class first.
 
Because you should not be implementing destructors at all but instead relying on the destructors of existing classes.
 
But that’s not always possibru.
 
@daknøk example?
 
@Cheersandhth.-Alf OpenGL shaders.
 
4:21 PM
Basically, if every class in your application has a manually written destructor, you're doing it wrong.
 
dude.. I cant find a way to instantiate that class
 
@daknøk What about them.
 
@daknøk well can't you wrap them?
 
@Cheersandhth.-Alf You can, but you’ll need a custom dtor.
They return a GLuint, so you cannot use std::unique_ptr.
Well you can, but you’d need to use make_unique<GLuint>(glCreateShader(GL_VERTEX_SHADER)), which is extremely silly.
 
You can do it if you convert that to a void*. (static_assert sizes and alignments if you want).
You can also do it if you write a wrapper that compares ints to nullptr.
 
4:24 PM
error goes in line 33 paste.ubuntu.com/1297829
 
Because that's all that is required of the thing you use on unique_ptr. It doesn't have to be a pointer.
 
I wrote this shader class a while ago. It uses a custom dtor.
@R.MartinhoFernandes what if sizeof(GLuint) > sizeof(void*)?
 
Useless trivia: you can make unique_ptr<T, crazy_stuff_goes_here> such that it stores a unique_ptr<T> instead of a T*. unique_ptr_ception.
 
we need unique_value
 
4:27 PM
@daknøk "(static_assert sizes and alignments if you want)." What machine would you want to run OpenGL on that has pointers smaller than 32-bits?
 
template<class T, class Destroyer, bool copyable = false>
class Resource;
// lol
 
is it right?? LexicalAnalyzer::LexicalAnalyzer lexicalAnalyzer(indata);
 
@rogcg can we LexicalAnalyzer.h
 
@R.MartinhoFernandes oh I missed the static_assert part. Whoops.
 
Anyway, deleting shaders is overrated.
 
4:28 PM
 
Not if you have thousands of different shaders.
You don’t want to leak all the memory.
 
@daknøk You mean, if you are constantly changing between thousands of different shaders?
 
main.cpp -> http://paste.ubuntu.com/1297829/
LexicalAnalyzer.cpp -> http://paste.ubuntu.com/1297831/
LexicalAnalyzer.h -> http://paste.ubuntu.com/1297886/
 
Because you if you need to use them all, you need to use them all.
 
Especially if you are not constantly changing between all them.
 
4:29 PM
@rogcg LexicalAnalyzer is in a namespace. Access it like LA::LA
 
@Tuntuni so?
 
@daknøk What?
 
@Tuntuni that would be the problem
 
@BobFincheimer Hm?
 
LexicalAnalyzer::LexicalAnalyzer lexicalAnalyzer(indata);
 
4:30 PM
ya?
 
@Tuntuni that's what I did.. Now it says undefined reference to `LexicalAnalyzer::LexicalAnalyzer::LexicalAnalyzer(std::basic_ifstream<char, std::char_traits<char> >&)'|
 
@Tuntuni I was just saying you are right
 
@R.MartinhoFernandes Say one time you use a set of shaders S, and another time you use a set of shaders T. You don’t want to keep S in memory if you don’t use them anyway.
 
@daknøk If you are always using them, you don't want to delete them. So you're not leaking them. QED.
@daknøk That's changing between them, silly.
 
@rogcg That is because your CPP for defining the LexicalAnalyzer is not in the namespace
 
4:31 PM
@BobFincheimer my cpp must be inside the namespace LexicalAnalyzer too?
 
@rogcg either add LexicalAnalyzer:: before everything in your LexicalAnalyzer.cpp or wrap the file in a namespace LexicalAnalyzer {}
yes
 
@R.MartinhoFernandes oh changing in that way? Well, you can only use one shader program at a time, so I thought you meant that by “changing”.
 
@rogcg You don't have the namespace inside the .cpp.
@BobFincheimer Beat me to it. :)
 
oh sorry
 
@Tuntuni i havent
 
4:32 PM
@rogcg sorry do: using namespace LexicalAnalyzer;
in your cpp
 
@BobFincheimer Couldn't he just wrap the whole thing into a LA namespace?
 
ok I'm gonna post my current code.. wait a sec
 
It would prevent name clashes in the future (if any), wouldn't it?
 
@BobFincheimer does that work?
 
@Tuntuni yeah the namespace and class being the same name is no fun
 
4:33 PM
Post it on damn Stack Overflow.
 
@BobFincheimer Heh. ;)
 
@rubenvb Then the definitions will actually define the interface
 
@BobFincheimer I didn't know you could use it for the implementation of them. I've been doing namespace bla { /*definitions*/ }.
 
using namespace does not place your definitions in that namespace.
 
4:34 PM
that was the impression I was under.
 
It only brings stuff from that namespace.
The way to place stuff in a namespace is to open it: namespace foo { blah blah }
 
@rubenvb yeah, but do not do that in the header, it won't work, and doing using namespace in any header is bad practice, tis only for cpp stuff
 
@Tuntuni @BobFincheimer
main.cpp -> http://paste.ubuntu.com/1297895/
LexicalAnalyzer.cpp -> http://paste.ubuntu.com/1297897/
LexicalAnalyzer.h -> http://paste.ubuntu.com/1297898/

I'm still having the undefined error for all my methods in .cpp file
 
ok. My world has not collapsed. Thanks to the robot.
^ this is weird in light of the Terminator franchise
 
Use an AbstractSingletonAddressFactoryProxyManagerEngineDecoratorBuilderBean, obviously. — daknøk 5 secs ago
 
4:35 PM
@rogcg can you quickly rename the namespace (change it to LA or something in both the header and the using statements in your cpp
 
</trollmode>
 
@BobFincheimer wait..
 
@rogcg I don'y know how the compiler is dealing with them being the same name
 
@daknøk LOL
@rogcg Try to wrap the whole LexicalAnalyzer definition in the .cpp into a LexicalAnalyzer namespace.
 
4:37 PM
Would anyone consider this ok? pastebin.com/AYGM5wQH
 
^ Needs one additional undelete vote.
 
I changed the namespaceto LA and before each method I did like LA::analyze(), and in the instantiation I did LA::LexicalAnalyzer analyzer(indata).

But still have the errors
 
@Tuntuni only that uppercase should be reserved for macro names
:-)
 
@Tuntuni no, you use a C-style array.
 
I want the structs to have the same name but they're different and I don't want to name things like something_SETTINGS, something_else_SETTINGS, ...
 
4:37 PM
@Tuntuni are you missing a typedef in that code?
oh, nvm
 
@Cheersandhth.-Alf oh. :p
@daknøk Could you explain?
@BobFincheimer ;)
 
@melak47 I will put a forum post explaining it for you and any one else who comes along cc @cat
 
@Tuntuni use std::array or std::vector. foo[] is confusing and vexing.
 
@thecoshman thanks :)
 
@rogcg I already gave the solution above.
 
@R.MartinhoFernandes so I have to put namespace stuff { } in my .h and .cpp file??
 
@rogcg Yes, that's what we've been telling you. :)
 
i think, as i recall, std::array does not provide the size as a compile time constant, and if i remember that correctly, that could be one valid reason to use a C array.
 
@Tuntuni what about in the main.cpp where I want instantiate the LexicalAnalyzer class?
 
4:40 PM
@Cheersandhth.-Alf as I said Saturday, make_array.
 
@rogcg what are the error messages now?
 
@rogcg Then either do using namespace LA; or LA::LA
 
like this..

undefined reference to `LA::LexicalAnalyzer::analyze()'
 
@rogcg The code you posted earlier!!!:::: using namespace LexicaAnalyzer;
spelled wrong!
 
I'm using LA for simplicity here. Type out the whole thing.
 
4:41 PM
I chagned everything for LA
 
@Cheersandhth.-Alf template<class... T> std::array<typename std::common_type<T...>::type, sizeof...(T)> make_array(T&&...);
 
@rogcg there is one good reason to use qualification and not a surrounding namespace in the cpp file, namely that you'll get compilation errors on things not declared in the header file
 
@rogcg you shouldn't need the namespace {}, you can use the using namespace if you spell LexicaAnalyzer as LexicalAnalyzer
 
@BobFincheimer No, using namespace won't help.
 
@daknøk I still haven't gotten into the real C++. :/ I'm still on that C with classes level.
 
4:41 PM
@R.MartinhoFernandes to define methods it should
 
Not that I can't understand it but I just haven't got used to it yet. :L
 
ok I'm getting confused. I'm gonna post the code and you tell me what's wrong.. Everyone is telling different stuff
 
@rogcg sounds good
 
k
 
@BobFincheimer No, it should not.
As I said above, using namespace is to bring stuff from another namespace into scope; it is not for putting stuff in that namespace.
@BobFincheimer ideone.com/MaFYWO
 
4:44 PM
main - http://paste.ubuntu.com/1297920/
.cpp - http://paste.ubuntu.com/1297922/
.h - http://paste.ubuntu.com/1297923/

now..what's wrong here..how do I fix it please?
 
// You can do the following, IIRC. LLVM does this, IIRC:
namespace A { void B(); }
using namespace A;
void B() { ... }
 
@R.MartinhoFernandes ideone.com/ZV2pcz
 
Yes
 
@R.MartinhoFernandes you declared it twice, not define then declare
 
@rogcg Once you do using namespace LA; there's no need to do LA::Lexical...
 
4:44 PM
@BobFincheimer Oh, sorry.
 
@daknøk Don't think so.
 
Just do LexicalAnalyzer
 
pretty sure that when you define it, you have to qualify it
 
You brought it into scope already by doing 'using namespace LA;'
 
@rogcg Either wrap things in namespace RA{} OR prefix things with RA::, NOT both
 
4:45 PM
else you just define some other function in the global scope
 
@R.MartinhoFernandes no problem
 
so I de-wrap my .cpp file and use using namespace LA, and do LA::method
 
@rogcg in the cpp file, just remove the namespace
 
Or maybe it only works for class members or something.
Anyway, I never use using namespace.
 
4:46 PM
@daknøk Most of them are not unqualified.
 
I only do namespace fs = boost::filesystem; in non-headers.
 
@rogcg Here, 1 second. I'll do it for you.
 
@daknøk @rogcg AND change the methods LA::analyze to LA::LexicalAnalyzer::analyze
 
Anyway, whatever happened to searching and asking on fucking Stack Overflow.
4
 
`namespace LA
{
LA::LexicalAnalyzer()
{
// default ctor
}

LA::LexicalAnalyzer(std::ifstream& input)
{
// ctor
indata* = input;
}

LA::~LexicalAnalyzer()
{
// dtor
}

// Makes the lexical analyzis
void LA::analyze()
{`
 
becomes `
LA::LexicalAnalyzer()
{
// default ctor
}

LA::LexicalAnalyzer(std::ifstream& input)
{
// ctor
indata* = input;
}

LA::~LexicalAnalyzer()
{
// dtor
}

// Makes the lexical analyzis
void LA::LexicalAnalyzer::analyze()
{
 
Please post code externally.
 
@R.MartinhoFernandes sorry
 
Your Markdown skills are terrible, you are terrible and I’m gonna plonk you.
 
@BobFincheimer Or just wrap everything into a namespace? I mean, namespace blahblah {code...}
 
4:47 PM
@daknøk plonk?
 
@Cheersandhth.-Alf I think you borked something.
 
@Cheersandhth.-Alf You borked the link.
 
^ Now it just need 5 reopen votes. I already voted before it was deleted, so I can't vote again.
 
@BobFincheimer no need to using namespace LA??
 
-6
Q: Simple string concatenation

mazen.r.fIf I have a string x='wow' in Python, I can concatenate this string with itself using the __add__ function, like so: x='wow' x.__add__(x) 'wowwow' How can I do this in C++?

 
4:48 PM
@rogcg yes.
 
@rogcg not if you prefix everything with LA
 
@BobFincheimer Plonk is the sound the user makes when he falls down to the bottom of someone's 'killfile'.
Like a black list. :D
 
Ell
hi guys
 
it's just the principle, that questions shouldn't be closed and deleted due to completely unrelated social issues and convenience for cats
 
@rogcg Three Options:
namespace LA { ... }
using namespace LA
prefix everything with LA::
pick ONE
 
4:49 PM
@BobFincheimer how does it know which namespace is LA.. because I include the .h file??
 
@rogcg Yes. It sees that the .h has some namespace LA. Then when you do LA:: you can access everything that is inside.
 
and that it deserves an answer that isn't directly technically incorrect
 
-3
Q: How to find minimum value from vector?

Cristi DroPsHow can I find the minimum value from a vector? int main() { int v[100] = {5,14,2,4,6}; int n = 5; int mic = v[0]; for(int i=0;i<v[n];i++) { if(v[i]<mic) mic=v[i]; } cout<<mic; } But is not working, what can I do?

Check out the for loop condition
 
lol
 
@Praetorian What with it? :D
 
4:50 PM
I guess this codeblocks has some problems. It still keep accusing the error.
 
Not like that , I want "oldschool" — Cristi DroPs 33 secs ago
 
@R.MartinhoFernandes I want to plonk people on Stack Overflow.
 
Nvm...
 
@BobFincheimer depends on whether it is header or implementation file, and in the latter case, which part of that file
 
@Cheersandhth.-Alf I am just talking about the CPP
@rogcg @Cheersandhth.-Alf this is just for the CPP, the header is perfect, it should use namespace LA { class ... }
 
4:52 PM
@R.MartinhoFernandes Poor guy's probably been told he must use a loop. Nevertheless, that comment is hilarious
 
@rogcg now your constructor is messed up
 
@Cristi For the record, min_element is from the last millenium. Is that old school enough? ;) — R. Martinho Fernandes 1 min ago
 
@BobFincheimer got it.. and in the main.cpp file?? dont using namespace LA, and start everything with LA::Class::...
 
@melak47 kyro.piotrl.pl/viewtopic.php?f=6&t=23 for dev's eyes only
 
@Praetorian If I were told to use a loop, I’d still use min_element or recursion.
 
4:52 PM
@BobFincheimer for the implementations of header-declared functions, use the explicit qualification. that way the compiler will tell you if you accidentally use a wrong name or something. the qualified functions must match the ones declared in the header file, which is not the case when you just wrap the implementations in a namespace
@daknøk huh
 
@rogcg that should be your ctor
 
@Cheersandhth.-Alf ugh reply fail.
 
@BobFincheimer I see
 
@Praetorian I really want people to realize that large swaths of what is called "modern C++" is old as fuck.
 
4:54 PM
@rogcg post your code with those changes, so I can see what you see
 
the short of it: you can't introduce something new in a namespace by writing a qualified definition outside that namespace. so it's a good way to ensure that only declared items, are implemented
 
@R.MartinhoFernandes You'd be surprised how many C++ programmers there are out there who're stuck in the MFC days, and have never used stuff from the standard library
 
I want the solution in C++ but I cannot use the ++ part of C++.
Again. The world is crawling with morons.
 
@BobFincheimer ok.. paste.ubuntu.com/1297955
 
@melak47 also what is your name on the forum?
 
4:55 PM
Are we still debugging this?
 
I was once told by a colleague that he feels it's not very useful to know the standard library because no one uses it
2
 
@Cheersandhth.-Alf that is a good practice, but the compiler is going to tell you if you didn't in fact define something you declared...
@rogcg remove the body of your ctor
 
@BobFincheimer i think you meant "and", not "but" ;-)
 
@Cheersandhth.-Alf yes...
 
and "linker", not "compiler"
 
4:56 PM
@BobFincheimer IDK.. after all this thing.. it still show the undefined error for all methods in LexicalAnalyzer. I try to build the main.cpp, and it shows this error
 
but that's only if it's actually used. which might not be the case with library code.,
 
@rogcg and LA::analyze() should be LA::LexicalAnalyzer::analyze()
 
unless one is good at testing
 
@rogcg and all your other functions too
 
@Cheersandhth.-Alf calmed down now I take it?
 
4:57 PM
@Cheersandhth.-Alf good point
 
I'm coming to the conclusion that database schemas without any context are just meaningless
a bunch of tables with some names mean fuck all to me without context
 
@thecoshman there was number of people getting excited here. i was not one of them.
but you were, as i recall
 
Firefox is gone apeshit.
 
@BobFincheimer no dude. I did that in my .cpp file, and it still happens when I try to build the main.cpp file
 
the reason i didn't need to get excited is that i was and am entirely right, while the ones opposing, were and still are wrong.
 
4:59 PM
@Cheersandhth.-Alf I was getting excited? hardly, I tried to ask what was wrong with the answers, and didn't appreciate the response. Still, no need to kick it all off again
 
@rogcg make those changes in LexicalAnalyzer.cpp NOT main.cpp
 
@BobFincheimer yeahh.. I changed in LexicalAnalyzer.cpp.
 
@R.MartinhoFernandes Engrish to the rescue!
 
@rogcg repost? :-(
 
but now I'm trying to run the program, by building the fils.. and it shows this error
 
4:59 PM
@thecoshman What?
 

« first day (737 days earlier)      last day (4203 days later) »