« first day (364 days earlier)      last day (4577 days later) » 

12:00 AM
so <int, float> does not select the specialization
 
Yeah that was what I was fiddling with.
 
@LucDanton you are totally free to design the primary template. any arity and type of the template parameters are allowed
 
time_t now=time(NULL);
struct tm *tm=localtime(&now);
tm->tm_hour;
if (tm_hour>12) {
tm_hour=tm_hour-12
}
so how does this work?
 
0
Q: Is there a way a partial specialization is always preferred over the primary template?

Johannes Schaub - litbI'm asking myself Can you write a class template and a corresponding partial specialization such that for any set of template arguments for the parameters, the partial specialization is taken by the compiler? For example template<typename T> struct A { }; template<typename T> ...

 
@JohannesSchaublitb I have one that appears to be working.
 
12:08 AM
xD
 
Do you want an answer or shall I wait?
 
you are free to answer
 
cpx
oh this discussion makes me want to read that templates in depth part that i skipped hmm.
 
extra points for c++03 xD
but this is a good c++0x solution
 
Oh noez! The pointz.
 
12:17 AM
I wonder whether template<typename T> struct A; template<typename T, typename ...U> struct A<T, U...> { }; works too
 
Seems like a stretch.
 
there is a very simple C++03 solution though :)
 
 
1 hour later…
1:44 AM
oh hai
 
just ordered
 
cpx
samsung?
 
cpx
ah galaxy II
 
it's a little big
but I guess it's still fine
 
cpx
1:51 AM
i only use phone for multimedia and internet never did for phone call.
 
xD
i wonder whether it will fit into my trouser pocket
 
2:06 AM
lol, GCC chokes on a <typename T::T> specialization.
 
2:17 AM
Oh actually I think it's the error message that is wrongly picked.
 
@LucDanton typename T::T should be fine I think. But there is no way such a partial specialization can be taken
 
@JohannesSchaublitb Yeah, GCC is trying to report that but the message is not right. More obvious cases (typename whatever<T>::type) yield the same error.
 
3:10 AM
Hey all... wow, this room is almost empty
 
 
1 hour later…
4:34 AM
Hi guys! I am pretty new to Cpp and i am having an issue porting some code from Java [I am a .NET Regular]... can anyone check this little code snippet? pastebin.com/m16FVtRQ
 
4:47 AM
@Drknezz I don't think there's any need for new here. Also I don't think that pair creation typechecks.
i.e. making an std::pair<int, Nodo> from (int, Nodo*).
 
fixed Drknezz:
class Grafo
{
public:
Nodo *Raiz;
map<int, Nodo*> Nodos;

Grafo(int V)
{
Raiz = new Nodo(V);
//Getting http://msdn.microsoft.com/en-us/library/s5b150wd(v=VS.100).aspx here
Nodos.insert(pair<int, Nodo*>(V, Raiz));
}
};
If you allocate a Nodo then the places where it's used need to be Nodo* type.
 
5:37 AM
Whoah, the 'relocation refers to a discarded section' messages from ld.gold are not errors. That's a relief.
 
 
2 hours later…
cpx
7:27 AM
I can't sleep.
 
I can't either
But it's 9:30 in the morning so not that bad.
 
8:03 AM
^ :D
 
0
A: running shellcode + vs2010

Alf P. Steinbach[ At the time I am answering the question is about why compilation fails for … #include<iostream> using namespace std; char sc[] = ""; #i've removed the shellcode int main() { int (*func)(); func = (int(*)())sc; (int)(*func)(); } This code is an attempt to execute da...

^ stomach-wrenching :-)
 
agreed.. in that i didn't understand a word of that answer :D
 
@Josh1billion did you understand the question?
 
not really, no :P
i tend to work in much higher-level code than what's going on there
 
oh. well he declares a function pointer. and tries to cast the address of his data buffer to function pointer, and then call that "function".
 
8:17 AM
low-level memory manipulation and the like are out of my scope (pun not intended 8))
ahhh i understand now
 
hi
 
hi deadmg
 
hi deadmg
hm i wanted to post a picture of beef stroganoff with fries, but i see sbi is lurking so better not :-)
 
8:32 AM
damn that sbi
do questions get upvoted here just for being well-written and precise? i asked a question tonight and it immediately received 5 upvotes, but i can't imagine why because it can't be a particularly interesting or insightful topic
 
@Josh1billion I have up voted questions simply because they are well written... (fwiw)
 
ah alrighty :)
 
man, the Internets here sucks
good thing I can go play Diablo 2
 
great game
gotta go, adios guys
 
chau =)
 
9:07 AM
@DeadMG Diablo 3 out yet?
 
9:50 AM
no
and I'm not convinced I want it in any case
 
10:22 AM
Howdy
 
10:54 AM
why i am getting error
 
You want strcmp(a, b) instead of strcmp(a < b).
But why are you writing a template when you can only pass in const char* anyway?
And why do you return a T? strcmp returns a bool, and you should do the same.
 
i am so idiot , thanks @FredOverflow for quick help :)
 
Oh wait, do you want to return the "smaller" string?
 
YES
 
const char* smaller_string(const char* a, const char* b)
{
    return strcmp(a, b) < 0 ? a : b;
}
@MrAnubis Does that work for you?
 
11:01 AM
@FredOverflow yes , thanks
@FredOverflow is it true some are born talent , i.e some have good ability to solve problems?
 
I wouldn't know.
 
suppose two persons are asked question , question is related to only problem domain which is known to both , is it the case one can solve quickly and other can't i.e reasoning is dependent from person to person?
 
@FredOverflow How are you today?
Studying?
 
@MrAnubis I would guess it depends on how long the people have been studying. It takes about 10 years to become a great programmer.
@ManofOneWay Watching South Park, does that count as studying? ;)
But I have the C++ standard draft open, just in case ;)
I was just wondering if std::min is specialized for const char*. Apparently, it isn't :(
 
@FredOverflow I'm afraid not! I'm in school studying real time systems .. :(
 
11:06 AM
School on a Saturday? But real time systems sounds like C++ related, shouldn't it be awesome to study them?
 
Saturday, yes. The exam is on Wednesday so I'm preparing ;)
I'm afraid not, this is mostly theory so it's mostly about different scheduling algorithms and determining whether a set of tasks is schedulable or not
 
sounds like OS exam
 
Next period I will have compiler design, which I hope will be awesome
@MrAnubis Kind of, RTOS specific stuff
 
@FredOverflow i am so worried about myself getting job, loosing my confidence day by day :(
 
11:24 AM
@MrAnubis How long have you been studying?
 
what should I do for a Matrix in C++?
 
@FredOverflow you mean c++ etc?
 
@MrAnubis yes
 
@vivek Download a Matrix class and use it. Or write your own.
 
11:28 AM
@FredOverflow around one year
 
can't use any third party code
 
@vivek then write your own
 
@FredOverflow I want to
 
@MrAnubis Okay, and when do you graduate?
@vivek What's the problem?
There isn't the one true way to write a Matrix class. Depends on what functionality you need.
 
@FredOverflow this year 2011
 
11:29 AM
but should I use vector<vector<short>> ? or something else
 
@MrAnubis How can you graduate after only one year of study?
 
I just have to represent a graph
so only 0 & 1 as value
 
@FredOverflow i started learning c++ in the end of 3rd year
 
@vivek Do you know the size of the Matrix at compile time or runtime? If runtime, is the size known at creation time, or can it grow later?
 
runtime
 
11:31 AM
@MrAnubis Okay so what did you learn in the two years before that?
 
it will not grow
 
@vivek How many nodes do you have? If you have a maximum of 32 nodes, you can store the matrix in a single int ;-)
 
@FredOverflow photoshop and 3dsmax ( off topic from graduation )
 
And what kind of job do you want?
 
@FredOverflow now i am complete interested in programmer job ( but some time before i was in to 3D graphics )
 
11:33 AM
By the way, questions about career and job opportunities etc. can be discussed on programmers.se
 
@FredOverflow 600000 :(
 
You might get great help asking there.
@vivek Then use a std::bitset, it'll eat up about 75 kb.
std::bitset<600000> neighbors;
 
@FredOverflow thought of that but size varies from 1-600000
 
@vivek Aha, so you need a construction-time variable length bitset.
 
@FredOverflow exactly
 
11:36 AM
I would be surprised if there wasn't something like that in Boost, but you could always roll your own with std::vector<unsigned char>. Just do the bit magic yourself.
I would write one for you, but:
> can't use any third party code
 
@FredOverflow by bit magic do you mean masking?
 
@vivek I mean stuffing 8 bits in a single unsigned char.
 
@FredOverflow It's fun that stackexchange has bought a swedish .se (programmers.se) and used .se as Stacked Exchange. It's not very logic =)
 
@FredOverflow ah, yes I can do that
 
Of course, for simplicity, you could start with only 1 bit per char. It will take up 8 times as much memory, but you will get correct code more quickly, and you can always refactor later.
 
11:39 AM
At first I thought you knew swedish!
 
Who, me? No, I know only German and English, sorry :)
 
also do you happen to know what's the best way to find if 2 nodes/vertices are connected in a graph?
 
Dijkstra's algorithm, conceived by Dutch computer scientist Edsger Dijkstra in 1956 and published in 1959, is a graph search algorithm that solves the single-source shortest path problem for a graph with nonnegative edge path costs, producing a shortest path tree. This algorithm is often used in routing and as a subroutine in other graph algorithms. For a given source vertex (node) in the graph, the algorithm finds the path with lowest cost (i.e. the shortest path) between that vertex and every other vertex. It can also be used for finding costs of shortest paths from a single vertex ...
 
my friend suggested a method whr you multiply the matrix with itself
 
sounds awfully expensive
@vivek Also, I don't see how multiplying a matrix with itself would get you anywhere. Did you mean multiply the matrix with a neighbor's matrix or something?
 
11:45 AM
hi everyone :)
 
hello
 
@FredOverflow btw which GUI lib you use (if any) ?
 
@FredOverflow Are you studying computer engineering?
 
@ManofOneWay He is a professor i think
 
@MrAnubis The worst there is. Swing.
 
11:47 AM
@FredOverflow java? , in c++ ?
 
@ManofOneWay I'm not a student anymore. But that doesn't mean I don't study in my spare time, of course :)
@MrAnubis Swing is Java. I have never done GUI in C++ except for some Win32 hacking which was an extremely awful experience.
 
@FredOverflow he said if after k multiplications matrix[i][j] != 0 then nodes i & j are connected with k-1 nodes in between them
 
@FredOverflow no , i meant in c++ , which GUI?
aah
 
I always mean to learn Qt. I think I still have a book on Qt lying around somewhere.
 
@FredOverflow Qt is easy
 
11:49 AM
But it started with new Something on the first page, and that made me a bit suspicious of Qt.
 
representing graph using matrix is really a hard job :(
 
I made a messenger in it once
 
@MrAnubis Why? Just put the neighbors as 1s in the matrix, done.
 
@FredOverflow when i had choice , i did it using node (pointers) based representation
@FredOverflow applying different algo ( bfs , Dijkstra etc) are very difficult for me in matric based graph
:)
 
Wait, nobody is telling you to use a bitset. If you want to use a list of pointers to nodes, go for it.
 
11:52 AM
@vivek cool
@FredOverflow i already completed my library completely from scratch ( no STL even) , though never used it :D
 
Is not using the STL something to be proud of? ;)
 
@FredOverflow no , was just telling , was my tone like prouding?
 
@FredOverflow sure, in the same way that you should be proud if you won the 100m dash after breaking your leg ;)
 
I just find it interesting that you can generally divide programmers into "it's no C++ without the STL" and "using the STL is cheating".
Oh, and then there are those that say there is no STL in the C++ standard. Yes, they are technically correct, but I don't want to start that discussion again :)
 
@jalf Hi :)
 
11:57 AM
hi
 
just curious has anyone in here used redis in their c++ program?
 
What is redis?
 
I'm trying to use a key value store and don't particularly want to write my own
 
@jalf btw you also teacher or SE?
 
@shuttle87 std::map? Or do you need something more powerful than that? ;)
 
11:58 AM
@FredOverflow, it's a key-value store
 
@MrAnubis SE == software engineer?
 
Well I'm trying to make a LRU cache
 
@jalf yes
 
that can be accessed by multiple machines
 
I guess that's me. I just write code, I'm not teaching anyone anywhere ;)
 
11:59 AM
Also I want persistence for the data, so std::map is not enough on it's own
 
@jalf you should teach ducks from time to time:
 
@shuttle87 well, I've never used redis :)
 
Rubber duck debugging, Rubber Ducking, or the Rubber Duckie Test is an informal term used in software engineering to refer to a method of debugging code. The name is a reference to an apocryphal story in which an unnamed expert programmer would keep a rubber duck by his desk at all times, and debug his code by forcing himself to explain it, line-by-line, to the duck. The process is to meticulously explain code to an inanimate object, such as a rubber duck. It is expected that when the programmer comes across a piece of code that is incorrect, they will realize this Similar terms *Cardb...
 
ha that's awesome
 
@FredOverflow are you saying I write buggy code?! ;)
 
12:02 PM
Everyone writes buggy code, except for Donald Knuth maybe.
3
 
Is there a standard way to write a non-copyable class?
 
there are several. I usually either use boost::noncopyable, or just declare the copy ctor private myself
 
thanks
 
12:20 PM
@shuttle87 In C++11, you can declare the copy operations as deleted.
But personally, I don't see the big advantage over declaring them as private.
 
true. All I can think of is cleaner compiler errors
 
The big advantage is that delete isn't yet implemented anywhere. Oh, wait.
 
well, I suppose deleting them also prevents the class' own members from invoking the copy ctor
makes the intent a bit cleaner I suppose
 
Oh, one of my students is called Oppenheimer. He must have heard that stupid question a million times already, but I guess I will have to ask it anyway...
> OMG Did your grandfather invent the nuclear bomb?
 
@FredOverflow, thanks for that bit of info regarding delete
 
12:26 PM
70
Q: What is The Rule of Three?

FredOverflowWhat does copying an object mean? What are the copy constructor and the copy assignment operator? When do I need to declare them myself? How can I prevent my objects from being copied?

@shuttle87 You can also find that info under "noncopyable resources".
 
thanks
 
1:15 PM
afternoon lads
 
hi
 
1:33 PM
Hey
What am I doing wrong?
std::ostream & operator << (std::ostream &s, const Mat4 &m);
std::ostream & operator << (std::ostream &s, const Mat4 &m)
    {
        for(int i = 0; i < 4; i++)
        {
            for(int j = 0; j < 4; j++)
            {
                s << m(i,j) << ' ';
            }

            s << std::endl;
        }

        return s;
    }
Output: 1
 
if the other output failed, e.g., stream full/closed
then output is a no-op
 
world::Mat4 mat();
std::cout << mat << std::endl;
That's all I do
and m(i,j) returns a float
 
folks
now I'll take a coffee
 
hmm coffee :)
 
@JohannesSchaublitb Do you see what's wrong with my code above?
 
1:38 PM
I will sip it for you!
@ManofOneWay wrong indentation, weird variable names
.
 
=)
What's wrong with the indentation?
and what is weird about the variable names?
 
You're flushing the stream when a simple newline would suffice :)
 
Even if I remove the s << std::endl I still get output to be 1
 
yeah, I didn't say it would change the result ;)
 
1:41 PM
anyway, depends on what m(i, j) does (can it throw an exception?), and on the state of the stream :)
 
hi guys
cold day today :(
say hi
 
All it does is,

    float &
    Mat4 :: operator () (int r,int k)
    {
        return m[4*k + r];
    }
 
hi
 
@Jalf hiya :)
 
where
float m[16];
 
1:43 PM
@jalf
 
@ManofOneWay returns a reference to the array element?
 
Will a reference to a float not display the actually value of the float in streams?
 
ideone.com/MtOj4 First seems saner and less boilerplate-y, right?
 
of course it will
as I said previously, it's vastly more likely that the stream is just in a failed state
 
Well, it could also be a class emulating namespace, but that feels so ugly to me.
 
1:49 PM
@DeadMG Okey, what does that mean?
 
it means that the stream is no worky
;)
 
it means that when I fail to answer meaningfully, you should use Google to attempt to determine what it is that I just said
 
Also, what's that nonsense about Code Search being shut down?
 
does facebook use its like buttons on other sites to determine the online status displayed to friends?
 
2:52 PM
I won't answer to this guy's last comment
he should be able to figure it out himself
 
I said
"he won't send-u-the-codez"
 
@JohannesSchaublitb Probably not, it wouldn't make sense to mark a person online on the chat when they're visiting other pages.
 
"piece of cord for the last issue":
 
Speaking of chats, why are there so few people here today.
 
3:05 PM
Hi.
@ManofOneWay Most Vexing Parse!
world::Mat4 mat(); is a function declaration.
If you compile with warnings enabled, your compiler you'll probably warn you.
 
Whoever is in charge of C++ grammar is a master troll.
 
troll ALL THE THINGS
 
@sbi Those "iterators with those operations combined in a single object" are what Andrei calls ranges.
 
3:34 PM
room topic changed to Lounge<C++>: No trolls allowed. We already have the C++ grammar for that. [c++] [c++11] [c++-faq]
 
Woah, nobody nitpicked on "copy constructor for type T must always take reference to T as the only argument", I'm disappoint.
No, really, where are you people?
 
BOO!
 
@CatPlusPlus What are you talking about?
 
My latest answer.
 
3:43 PM
I believe that it can also take other arguments which may be defaulted
and in addition, you never touched on const
 
It also has to be an lvalue reference.
It doesn't have to be const.
 
I never said it did
 
std::auto_ptr.
 
all I'm saying is that your answer doesn't mention the possibility
 
Not as a possibility, but as a must.
 
3:45 PM
argghh, fuck you university, your system doesn't work and I can't access my codes¬
 
Well, I've added a quote with all possibilities listed, so it's all good and fluffy.
 
We don't need any more auto_ptrs.
 
Who are you to forbid people from unloading a magazine into their feet!~
 
I always managed to miss with auto_ptr
 
Someone is trying to do something "dynamic" with static_assert.
 
3:51 PM
How is C++ grammar a troll? :)
 
I hate Wikipedia...
 
Hatred (or hate) is a deep and emotional extreme dislike, directed against a certain object or class of objects. The objects of such hatred can vary widely, from inanimate objects to animals, oneself or other people, entire groups of people, people in general, existence, or the whole world. Though not necessarily, hatred is often associated with feelings of anger and disposition towards hostility against the objects of hatred. Hatred can become very driven. Actions after a lingering thought are not uncommon upon people or oneself. Hatred can result in extreme behavior such as violence, ...
 
2 hours ago, by Man of One Way
world::Mat4 mat();
std::cout << mat << std::endl;
See how many regulars were trolled after this.
 
it prints out "1"
"ah, why does the matrix only contains a '1'!?"
 
let's be fair
he didn't show that code until after
he only showed the operator<<
 
3:57 PM
16
Q: Typo with "cout < myint". Why does it work?

Johannes Schaub - litbI have this code and I searched for hours why it fails to print my income int const income = 0; std::cout << "I'm sorry, your income is: " < income; Until I found I missed to write << but wrote <. Why doesn't the compiler detect this and error out? I'm not sure why comparing ...

 
lol @tagline
 
I guess the function decays to a function pointer, and the function pointer is then converted to a bool, and streams display bools as numbers by default? That's brilliant :)
 
bwilliunt
 
Wait, how can there even be a pointer to a function that is only declared, not defined?
@JohannesSchaublitb lol
 

« first day (364 days earlier)      last day (4577 days later) »