« first day (213 days earlier)      last day (4735 days later) » 

8:00 PM
If you have a constant size, then that's even more ugly.
char p[12]; would suffice
 
Unless I want to reuse p
char* p = new char[12];
delete p;
p = new char[13];
 
Yeah, just use std::string.
 
std::string literals are not modifiable either if I remember correctly.
That whole conversation last time, where it makes a new one all the time.
 
There are no std::string literals, std::string("foo") makes an internal copy of the literal, and that is writable.
 
ok got it.
Don't really use std all that much.
 
8:02 PM
is there a good diff tool on Linux, similar to FileMerge on OSX?
 
Don't write C in C++, and you'll be much happier.
 
I don't
I write MFC in C++
 
CString?
 
But when passing data across platforms, I use primitive types
Lots of CStringing going on.
Don't really care for CString either.
It complicates things.
As do CBitmaps
 
Err what do you mean by "platforms" and "primitive types" out of (morbid?) curiosity?
 
8:04 PM
CString is a nasty COW thing
 
AH YES.... CString is the COW.... not std::string
 
Moo.
I'll be Cow Plus Plus next time.
 
@Luc Probably using the wrong words but I don't know what to call it.
Passing information in C form.
 
primitive types being only pointers, and in-built value types, basically
 
bits, bytes, and ASCII characters.
ints, etc.
No, don't use pointers.... I don't know where the data is going.
 
8:06 PM
C interop usually sucks, but you can easily drop down to char pointers and ugly stuff like that as needed.
 
could go in email, could go inter records in a database.
 
@Xaade char* p = new char[12]; delete p; is also undefined behavior ;) You have to release the array via delete[] p; (note the square brackets).
 
@FredOverflow whoops.... details
I knew that
 
C++ is all about details.
 
you know what amazes me?
 
8:11 PM
I knew that... just forgot about the []
 
if you have std::unique_ptr<T[]>, then the default deleter is delete[], and it's released correctly
but if you have std::shared_ptr<T[]>, it isn't
there was even a defect report on it and they chose not to change it
like, seriously, what the fuck?
 
@DeadMG Because the deleter isn't part of the type of std::shared_ptr I assume
Wait
std::shared_ptr<T[]> is dubious
 
no, it isn't, but it can still infer from the type at hand that it's wrong
 
How does that work? Is there a specialization?
 
yeah
I've never actually used this feature for unique_ptr, and I'm not wholly sure how unique_ptr<T[]> arises, but I know for a fact that the Standard mandates it's correct selection of the correct deleter
 
8:13 PM
How does that work? new T[n] is still a T*, right?
 
well, I assume that it actually returns a T[]
 
How does it know it's actually an array?
 
Requiring users to specifically write std::shared_ptr<T[]> { new T[n], [](T* p) { delete[] p; } } seems harsh then
 
std::unique_ptr<decltype(new int[5])> x; // gives int*
 
@FredOverflow T[] is a distinct type from T*
so all is needed is a specialization
did you mean in relation with make_shared or?
 
8:16 PM
Compiler accepts
std::unique_ptr<int[]> x(new int[5]);
 
Then you can do x[i]
 
@DeadMG Nope, 5.3.4 §5 clearly states:
> both new int and new int[10] have type int*
 
logically, if you had it as unspecialized, then the constructor argument should be an int[]*, not an int*
 
There is no such thing as an int[]*.
 
of course, this still isn't that helpful, because you can't do
 
8:18 PM
@FredOverflow But when does the compiler need to know the difference since the user specifies what kind of [unique|shared]_ptr he/she wants?
 
std::unique_ptr<int[5]> x(new int[5]);
so if you have a type T, then it still isn't generic for if T is an array type
 
@DeadMG I don't think that was the aim of the specialization
 
Huh, I've downvoted a question but didn't get -1.
 
especially since as Fred pointed out new T gives U* whether T is U or U[N]
can't write generic code without some traits/specialization I'm afraid
 
I think that it should and could be a lot more possible than it should be
 
8:20 PM
@DeadMG std::unique_ptr<int[5]> does not compile, you have to use an array of unknown bounds instead.
 
for example, if you have a function that takes void, you can't pass it any argument expressions- even if those argument expressions are void
 
> 2011-05-12: Question downvotes are "free" to the downvoter and will not be subject to a -1 rep penalty. Downvotes to answers are unaffected and still "cost" 1 reputation to cast.
Aw, and how am I supposed to make my rep even now?
 
@CatPlusPlus Vote 9 answers down?
 
@FredOverflow Finding downvotable question is easier. :(
 
Also fine.
 
8:26 PM
shared_ptr comes free with that since std::default_deleter is specialized for T[]
Personally I have my own make_unique since the Standard Library doesn't propose one (which I consider is the real offense)
 
@LucDanton Are you serious, there really is no std::make_unique? WTF?
 
also make_shared handles allocators but not deleters
Right a bit of google reminds me that the intent of make_shared is to make a single_allocation
 
hello all
 
I guess this wasn't designed with auto in mind
(never mind the _ in single allocation)
 
@CatPlusPlus you are a true obsessed repwhore, aren't you?!
59 mins ago, by DeadMG
who gives a crap about paper?
epic :)
 
8:36 PM
I give a crap about toilet paper!
 
loo roll perhaps, gives a crap
 
lol
 
@FredOverflow I suppose none of this was intended for convenience/generic code in the first place. I expect an idiom to be codified and one day pushed into boost then.
 
@DeadMG so how's things? did rewrite all what you lost earlier today?
 
8:37 PM
yes
and it actually turned out to be of much beneif
benefit
 
@LucDanton Oh wait, make_unique is not needed from a memory perspective, because unique_ptr has no shared state that needs memory on the heap :-)
 
it is needed from a syntax/usability perspective
well
actually, I guess that auto ptr = std::unique_ptr<T>(...) isn't really less than auto ptr = std::make_unique<T>(...).
 
how would you make something unique?
 
@FredOverflow Yes, my make_unique is to avoid repetition in cases like std::unique_ptr<T, Deleter> { new T { a0, ..., an }, Deleter { b0, ..., bn } };
 
if it happens to be shared already, then you're screwed no?
 
8:40 PM
So I have tons of template machinery to transform 27 characters into auto
so worth it
 
so anyone did something interesting today?
I spent three hours on the phone... hmmm
 
I ate some ice cream
 
and is that something your stomach is ok with?
 
not really
but it didn't bitch that loudly last time
 
8:44 PM
hahahaha
 
Is that Tim O'rly?
 
donno
you guys know about lolcode right?
 
Ah, it's O'RLY Media apparently
 
LOLCODE is an esoteric programming language inspired by the language expressed in examples of the lolcat Internet meme. The language was created in 2007 by Adam Lindsay, researcher at the Computing Department of Lancaster University. The language is not clearly defined in terms of operator priorities and correct syntax, but several functioning interpreters and compilers already exist. The language has been proven Turing-complete. Language structure and examples LOLCODE's keywords are drawn from the heavily compressed (shortened) patois of the lolcat Internet meme. Here follows a Hell...
 
yeah
 
8:46 PM
 
Okay here is my first attempt at make_unique:
#include <memory>
#include <utility>

template <typename T, typename... Args>
std::unique_ptr<T> make_unique(Args&&... args)
{
    return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
}
 
you forgot the deleter
 
All those dot-dot-dots make me dizzy!
 
@FredOverflow does that not assume that the arg you pass is unique in the first place? I mean if you pass it a raw pointer to which other pointers also hold references, then this will not be unique, or will it?
 
@DeadMG Where would you put that in the type list?
 
8:49 PM
@FredOverflow You can't, the way variadic templates work
You need some convention
 
@TonyTheTiger You pass constructor arguments to T, and a new T will be constructed. You don't pass the actual thing that is going to be shared. (Or are you talking about using unique_ptr in general? Then the answer is: don't do that.)
 
@Tony: That's your own dumb fault if you do that
 
@DeadMG well true, but I kinda hoped that would be the point of make_unique
or did I get it wrong once again?
 
the purpose of make_unique is to construct a unique_ptr
nothing more, nothing less
 
i.e. you can't have template<typename... Pack0, typename... Pack1> void func(Pack0&&..., Pack1&&...);
 
8:51 PM
@DeadMG then it should be construct_unique, cause I understood under make that you make something unique that wasn't in the first place
but I guess that wouldn't really work
 
Ah, one could misinterpret the name as "make something that was once shared now unique". That's not what it stands for.
 
you can construct a unique_ptr from a shared_ptr if you want that
 
@TonyTheTiger There's boost::make_shared, which is coming as std::make_shared
 
make_blah is an established naming convention for creating stuff. See make_pair.
 
but I'm not wholly sure of what happens if you do that
and make_shared
 
8:52 PM
@FredOverflow that's how I first understood it, therefore I had the confusion
 
make_tuple soon
 
make_mess by any chance?
returns UB, for your entertainment :P
 
lol
char make_mess() {
    return *(char*)rand();
}
 
@TonyTheTiger construct would be misleading, because it does not merely construct an object, it creates it. I would say create_unique would be a good name.
 
@FredOverflow yea that would indeed be a better name
 
8:54 PM
void make_mess() { main(); }
 
you know
we could probably come up with six million billion trillion different things to put in make_mess
infact, probably infinite
what I like about Visual Studio is that it lets me recurse main
 
Why would you ever want to do that?
 
yea there's so many things that are UB in C++, not even real
 
I don't quite recall
 
And if you really need it, just call some different function from main as the only statement, and then recurse on that.
 
8:55 PM
yeah
that's why I don't get why doing it is undefined or something
because you can trivially un-undefine it if you want to do it
 
Also known as define ;)
#define define unundefine
 
lol
#define NULL rand()
 
#define NULL (true * false)   // this actually works!
 
lol
did you see that Daily WTF about TheBomb?
 
Can't I do rollbacks in this chatroom? :(
@DeadMG Too hackety-hack-randomish for my taste.
 
8:58 PM
it's hilarious
and creative, for sure
 
I saw that, funny way to put bugs in one's code
 
I must say, variadic templates are still kinda black magic to me. It took me forever to come up with new T(std::forward<Args>(args)...). Is there a good tutorial on them?
 
apparently, an amazing amount of people don't know about the magic of ...
 
hahaha
@DeadMG it's magic...
lol
 
@FredOverflow I don't remember one particular resource, only short examples like what you wrote. I learned by experimentation
 
9:02 PM
Everytime I use ... on slides, I explicitly mention that this is not abbreviated pseudo code, but correct syntax :)
 
apparently, ... is valid, Python I think it is, and it throws a NotImplemented exception
 
The Dark Art of Variadic Templates, sounds like a good title for a new science fiction book
 
There's only ... and sizeof... as primitives in any cases (unpacking tuples is a pain)
 
Xeo
@DeadMG #define if(X) if(X) (void)0; for(;;) ?
 
@LucDanton I didn't know about sizeof... yet :)
 
9:04 PM
@Xeo: But that would instantly show up
the first if statement, program hangs
 
Xeo
Well, it is refineable.
 
what you might try is
 
@FredOverflow There you go, now you know everything!
 
@LucDanton what's it for?
 
#define if(X) for(; rand() && X;)
hangs the program for a random amount of time
 
9:06 PM
@TonyTheTiger The name is deceptive, it has nothing to do with regular sizeof. It's the size of the variadic pack
 
Heisenbug
lol
 
the problem with using macros in this way is that parameterization of the macro can have troubles
 
I don't understand macros very well, still black magic for me
 
if X contains brackets, then the preprocessor will barf on it
 
i.e. template<typename... T> struct how_many { const int value = sizeof...(T); }; static_assert( how_many<int, long, double>::value == 3, "Error" );
 
9:07 PM
"Error", what a descriptive error message
 
I'd expect 3 == 3 to hold
 
@TonyTheTiger In C++, all you need to know about the preprocessor is #ifndef, #define and #endif ;-)
 
#include?
 
@DeadMG Oh yeah, and that :)
 
you might also need #X as a stringize and X##Y as token pasting
 
9:09 PM
@FredOverflow I know that, so I'm good basically :)
 
@DeadMG Only if you define your own macros.
 
yes
which may be necessary in C++
 
Xeo
Understand Boost.Preprocessor. See you in some month. :)
 
lol
 
ugh
I need a good project as my C++ pet project
any suggestions anyone?
 
Xeo
9:10 PM
TMP
 
Damnit, I think my printer has bit the dust :( I can barely read the printout.
 
Xeo
I could waste all my day on it
Just write random stuff in TMP
 
@TonyTheTiger Tetris
 
Xeo
or try to recreate Boost.MPL
 
@FredOverflow hmmm interesting
I was thinking about Sudoku solver today
 
Xeo
9:11 PM
As a nice side effect, you'll come to like <, > and ::
 
hahah
@FredOverflow what GUI lib should I use?
 
@TonyTheTiger sfml-dev.org
 
@FredOverflow fml
 
One of the few OO graphics libraries for C++.
 
9:13 PM
@TonyTheTiger What is that?
 
heard a lot about wxWidgest
 
@FredOverflow fml is an acronym for Fuck My Life... just funny cause the lib is sfml
 
You can learn a lot about OO design by writing a game in C++.
 
I've done it
 
@FredOverflow you think I could do it in VC++ 2010 express?
 
9:15 PM
yes
 
@TonyTheTiger Does it have a C++ compiler? Then yes.
 
@FredOverflow ok
 
Have you written any other games previously?
Like Guess The Number or Hangman or Tic Tac Toe?
 
Xeo
@Tony: If you start to make a game, I guess will you'll come to like Gamedev.SE.
Also, a really cool site (where I learned making games in C++ (with SDL)) is this one
 
@Xeo yes I should, once I get started
and if I have questions
 
9:21 PM
I went straight into DX
didn't like any of the wrappers
SDL is a C interface
 
0
Q: Algorithm to create flow chart [A little guidance??]

SudhOK, I know it's a vague question, but I seem to be stuck with logic here...I want to create flow charts of the input programs. I hav been thinking about it since two days and can't get a best general approach...So i look desperately at you guyz to help me here....may be there is something small I...

Well I understand that it's a C++ forum...and my question is related to JAVA(whose chat room is not active..:( )...but what really I am asking for a logic...so can any one help me in above?
 
Is this chat room labelled "Spam questions"?
no?
then it's generally considered that once you ask a question on the main site, that you are already receiving the maximum attention
 
Xeo
@DeadMG You should maybe reread the newbie hints, second sentence. More attention, since some of us may not constantly be F5'ing SO proper.
 
@TonyTheTiger Sounds like a fun project, especially if you like sudoku.
 
@Xeo: It only specifies C++ questions
 
9:26 PM
@DeadMG: well just trying to get some help..is it wrong????....:O
 
yes, it is wrong
if I want to answer proper questions, then I will view the main site
 
@TonyTheTiger I only started to understand OO once I learned about design patterns.
 
but it says:
If you want to ask a C++ question here, you are welcome to do so,
 
Still waiting for a C++ question then
 
9:27 PM
more than that, we all have the right to disagree with those hints
 
Xeo
@DeadMG Derp, overlooked that [java] tag. But you're also complaining about C++ questions being linked in here
 
yep
 
Xeo
Sure, but then don't make it sound like we all disagree with them.
> Is this chat room labelled "Spam questions"?
 
Btw, Qt is quite good for simple games. My Tetris gets up to 60 fps using only the standard drawing libraries (without any fancy GL stuff).
 
ummm...ok you mean if it is a C++ question..it's allowed?
 
9:28 PM
I don't recall being consulted on the newbie hint's contents, and my name sure ain't on it, so I'm perfectly fine to disagree with it
 
and I was just asking about the logic???
 
@Xeo: That's sarcasm, not anything indicating group approval
@Sudh: Then wait for someone to answer
 
but I am a newbie...and that would be the first thing i would read and try to follow...
 
then sue whoever created them
 
argghhh...ok you win I go...
 
Xeo
9:31 PM
@DeadMG I think it's time for me to go to bed for today, as I'm clearly quite sleepy and I'm prone to ranting when I'm too sleepy.. >_>"
 
@StackedCrooked I looked at it today, but I couldn't find much info about the backtracking algorithm they use
or Wikipedia refers to anyway, I know there's other ways to implement it, but the backtracking seems the most fun to me
 
I'm not familiar with sudoku so I don't know if the algorithm is really difficult.
@TonyTheTiger yeah, if it's for a pet project you can try to invent your own algorithm and see how far you get. Common sense can get you pretty far.
 
@StackedCrooked huh?
ugh
1>sfml-window-s.lib(WindowImplWin32.obj) : error LNK2001: unresolved external symbol "_declspec(dllimport) public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (__imp??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@­@Z)
 
It's dark.
@TonyTheTiger The efficient google query is: LNK2001 site:stackoverflow.com
@TonyTheTiger Linker errors can be daunting, you never learn about them in school and you'll have to deal a lot with them..
 
@StackedCrooked thing is that it's an external lib
ugh
I know, I just did a C++ project and some linker errors took me days to resolve
 
9:43 PM
First thing that I check is that all VS projects are using the same runtime library. You can check this in each project's settings: "Configuration Properties" -> "C/C++" -> "Code Generation" -> "Runtime libary". Make sure all of them are the same.
And then also make sure all libraries are included in your main project.
 
I windows, can I with the sfml lib create a window in a mere console project?
 
9:59 PM
@TonyTheTiger I think it is possible, but if you want a Window and also a console then I'd go would create by project as a Windows application and attach a console to it.
 
@StackedCrooked hmmm ok, funny my sf::Window ctor crashes with access violation
 
Hm, I'm not familiar with sfml so don't really know that it could be. Always keep in mind that many noobs have gone before you and asked about it on forums. Probably there are a few out there that answer exactly your question.
It's kind of embarrassing to realize how much of my experience is built upon internet searches.
 
@StackedCrooked Mine too :) So no worries :)
going now, gotta get some sleep
 
Ok, good night :)
 

« first day (213 days earlier)      last day (4735 days later) »