« first day (1368 days earlier)      last day (1468 days later) » 

1:19 AM
https://chat.stackoverflow.com/transcript/message/49060471#49060471
can somebody please help me on this?
 
 
8 hours later…
user6461957
9:36 AM
Looks like it requires special knowledge, and there's a high likelihood that this can't be answered here.
 
user6461957
Or maybe rehash it in a way such that it requires a potential respondent to comprehend it via C or C++ knowledge only.
 
user6461957
Thus, generally please try to have the answerer in mind when posting such questions. I don't know anyone here that can read minds.
 
user6461957
;)
 
user6461957
Also don't take it personally when it seems like people here are "ignoring" you. No they don't. They just don't know any better. ;)
(E.g. folks like PeterT et al. are generally helping out when they can.)
 
10:16 AM
 
@PeterT I still think that I have a problem in understanding how returning things works. What can I read (with some examples for each possible case) in order to understand? I feel like I don't know what constructors and when are they invoked when returning from function. And I saw that from C++11 The way returning by value happens is different from earlyer version where the copy constructor was called.
I found some examples but they don't illustrate what I need (they are basic examples of functions returning by values, by reference or by pointer)
 
Yeah, I don't know if I can help you very well there. I didn't fully understand the rules until I learned how it's implemented in specific cases (how calling conventions work). So for me reading the C++ rules alone just didn't make sense.
But conceptually the C++ rules don't depend on how any specific system implements them.
 
But I tried to test them yesterday and nothing worked as I expected and ... i dont know...
Maybe I should ask a question on SO and wait for some different approaches
 
11:00 AM
@PeterT it looks like now exists the copy elision which makes the program to not call the copy constructor anymore
 
Yes, that's what I meant with the "yes it can involve a copy, but doesn't always."
 
 
3 hours later…
1:53 PM
Hi. Is there some simple way to implement a proxy class in C++? I.e. which only overrides 1-2 methods of some other class and forwards all the rest.
 
@DanM. what doesn't work with normal inheritance? I can think of maybe constructors, but you can include those with a using directive
 
@PeterT because it needs to happen after the class has already been modified.
it, meaning wrapping the class in proxy.
I.e. Foo*foo = createFoo(..); some emthods called on foo.
FooProxy * proxy = FooProxy(foo).
 
5 messages moved from Lounge<C++>
 
2:09 PM
@DanM. nah, there's not really a quick and easy way to do it. You might have like a hidden implementation type that you reference from both but that's not really quick or easy.
there's some reflection proposals that might enable it in future versions but for now there's no quick and easy way to solve a problem with this exact API.
 
@PeterT
Ok, thanks
 
3:05 PM
Is there a way of doing something like this:
std::tuple<int,int,int> t;
std::pair<int,int> p(1,2);
t=std::make_tuple(p,1);
 
std::tuple_cat(p,std::tie(1))
can work
apparently support for pair,array, etc is not mandated, but alllowed
 
Would it be safe if I use that in my homework ?
 
I'm not your teacher
 
I'm saying , can anything go wrong using that ?
errors and stuff
 
yeah, if the library implementation doesn't have a specialization for pair it might fail to compile
 
3:10 PM
okey I shall not use that
 
 
1 hour later…
4:22 PM
What is the difference between lambdas and templates?
 
nwp
4:33 PM
They are completely different things. You'd better off asking what they have in common and "being part of C++" is about all.
 
Ah okay. What do they have in common? I'm writing a confluence page and someone at my company thinks they have similarities so I'm to investigate that.
 
nwp
4:57 PM
Have you considered buying a book instead?
 
Waste of money.
 
nwp
So let me get this straight. You are writing a confluence page about C++ and don't know the difference between lambdas and templates and you think buying a book that explains this stuff is a waste of money?
 
Does it really matter to you?
 
nwp
Yeah, I'm trying to help. Understanding the problem is part of that and currently I'm having trouble.
 
 
3 hours later…
7:46 PM
I have just tested this: if two maps have the same set of key/value pairs, they will == to true. Are there cases where they wouldn't be equal?
Test code:
#include <iostream>
#include <string>
#include <map>

int main()
{
    using namespace std;
    std::map<string, string> map1, map2;
    map1["foo"] = "bar";
    map1["foo1"] = "bar1";
    map1["foo2"] = "bar2";
    map1["foo3"] = "bar3";

    map2["foo3"] = "bar3";
    map2["foo1"] = "bar1";
    map2["foo"] = "bar";
    map2["foo2"] = "bar2";

    if ( map1 == map2 ) std::cout << "true" << std::endl;
    else                std::cout << "false" << std::endl;
}
 
nwp
8:24 PM
No, that is how std::map::operator== is defined. I guess you could implement the operator== of the key or value in a strange way, like randomly or with a counter or something to break it, but otherwise it should be pretty safe.
 
 
1 hour later…
9:28 PM
@nwp ok, thanks!
 

« first day (1368 days earlier)      last day (1468 days later) »