« first day (291 days earlier)      last day (2568 days later) » 

1:02 AM
@nwp really though, when I said that I wanted to pass constexpr I meant any compile-time value. This was probably misleading.
 
 
13 hours later…
1:39 PM
Hi Guys. I'm trying to crosscompile some libs using cmake (3.7+ version) it's set compilers and sysroot correctly for my main cmake files, however my findLIBNAME.cmake scripts still looking for libs in /usr/... instead of sysroot_path/... Why this happen and how could I fix this?
 
hi guys
@milleniumbug You told me yesterday the leak was indirect. I changed the code a bit and now I get direct leak: pastebin.com/raw/40UYXLdc
I just want notice that if I clear the set before deleting the pointer, I don't have any memory leak.
 
how do you delete the pointer?
because it looks like the destructor of std::set isn't called
 
I simply call delete entity;
Memory leak:
       for (Entity *e : deletes) {
            delete e;
        }
Without memory leak:
       for (Entity *e : deletes) {
            if (e->getType() == PLAYER) ((Player*)e)->resetCache();
            delete e;
        }
 
is the destructor of Entity virtual?
 
no
is it wrong?
Player class extends Entity class
Entity has destructor (it isn't virtuak)
Player doesn't have destructor
 
1:51 PM
if you inherit from Entity then you need to make Entity's destructor virtual
 
OMG! IT WORKED!
I didn't know that the destructor must be virtual.
@ratchetfreak You just solved my problem I was facing three days :D
I'm so grateful to you
 
2:08 PM
and here's the relevant SO question: stackoverflow.com/a/461224/731620
 
 
2 hours later…
3:48 PM
Hello everybody

I have a question about C++, but it is sort of a non-technical question.
 
1 message moved from Lounge<C++>
 
I have on one hand a C++ program using openCV which displays images every now and then. I am currently writing another program using udp that will be in charge for the transmission of those images.
I would like to know what would be the best way to pass those images from the openCV code to the other program that will send it.
Shall I just save those images in some folder and let the other program scan that folder for changes on a regular basis?
 
if these are two different programs then you have no other way than use some kind of inter-process communication
files are one, but there are other ones
 
@milleniumbug indeed these are two different programs.
 
sockets, shared memory, signals...
 
3:52 PM
shared memory will be the fastests
 
I am just affraid that with files the "network transmitter" will maybe try to start send the image while it is not completely written to the hdd
 
then add some IPC to sync
 
@ratchetfreak Do you think this would be the best and easiest way to proceed?
from an opencv stand point I guess that just saving the files on my hdd somewhere may be the easiest solution.
 
on linux a simple option would be to save a file somewhere, and then send a signal to the other process, which would then read it
 
a named pipe can let you avoid the disk roundtrip though
 
3:55 PM
guess what...
I am combining Qt (for transmission and gui) and openCV (image processing) what shall I google to know more about those "signals"?
 
Qt's signals are only internal to the application
 
"linux signals", but, of course, this assumes a POSIX-style system, that is, not-Windows
otherwise you can simply keep a receiving socket open in the other program
since it's already using networking
and allow connections only from localhost
 
so the openCV program should use sockets to transmit the image to localhost. And then from localhost it should pass through my qt sender to reach my qt receiver?
You sure?
 
yes, a network connection that connects on the same computer
but from one program to another
 
I am not an expert. I totally understand you but sending info from one program to another program on the same machine via sockets sounds...
@milleniumbug
 
4:02 PM
it's actually done IRL
 
If this is the easiest I will definitely look at it. What would be another viable option?
 
it's not the fastest (as in bandwidth), but it's the most portable
you can use pipes
as ratchet freak suggested
 
what would be the downside of using pipes? portability?
 
windows also has named pipes but they are in a different namespace from files
 
hmm
 
4:07 PM
and in windows named pipes get cleaned up when the last process having it open shuts down
those are the primary differences IIRC
 
4:35 PM
@milleniumbug would you mind if I ask you a stupid question?
I am not a oop expert. I am waay more comfortable with C
When I click on pushButton 3 on my gui it should send a udp message. However I am not entirely sure I should make that private variable in udpClient.h
(don't look at the ip address I wrote...)
 
sorry, not familiar with Qt
 
@milleniumbug it is just a general oop principle, nothing specific from Qt afaik
whenever I click on the pushbutton the function on_pushButton_3_clicked() gets executed (that's the only thing which is specific to Qt as it uses signals ans slots and stuff) but all the rest is typical oop stuff that is also used in Java etc...
@ratchetfreak any idea?
 
5:41 PM
Hey guys
How can I create a constructor for a class X that accepts a instance of a class Y
when class Y is declared after class X
like
class x{
x(y foo){}
 
forward declare the constructor
struct Y;

struct X
{
    X(const Y& y);
};

struct Y
{
    /* ... */
};

X::X(const Y& y)
{
    /* implementation */
}
 
Woah
That first line, struct Y;
Are you "foward declaring" the struct Y itself?
I didn't know we could do that
 
pretty much
before the actual struct Y declaration, Y is a so called "incomplete type"
which limits what you can do with it, but allows you to use it in declarations
at the point where X::X(const Y& y) is defined, Y is already complete
 
So I fowardg declare the type and the constructor
nice, got it
 
 
4 hours later…
10:12 PM
sup? Does C++14 have any means for disabling code blocks like if constexpr which it does not have? Could I use enable_if for a hack?
 
yes, you need to use SFINAE or tag dispatching
 
Could you give me a slight tip about the idea of using SFINAE? Do you mean using functions?
 
yes, with what C++17 can do with if constexpr (condition) { ... } else { ... } you need to put the code inside each of the branches in their own function
 
then these two function can be overloaded
 
10:22 PM
enable_if won't let me easily reuse large chunks of code.
 
I think someone implemented emulation of if constexpr with tag dispatching and generic lambdas, but I can't find it
hmmm, found it
in Lounge<C++>, Sep 7 '15 at 17:37, by melak47
teehee, static_if ^_^ http://coliru.stacked-crooked.com/a/29db3f4507bf5b0c
 
Thanks, will try.
What was the reason for prohibition of templates in local classes?
Or was there any?
 
10:41 PM
I don't think there's a reason for this
it's rather the other way around
first you introduce structs
then you introduce templates
then you introduce a way to declare structs locally
...but you aren't 100% sure how this is supposed to interact with the rest of the world
so you first implement the simple parts
that is, the non-template classes
because, well, it's 19 years already after the first C++ standard was released
and there are popular compilers which don't implement it fully
or with bugs
 
@milleniumbug The only compiler that ever even made a serious attempt at implementing it completely was EDG (and among EDG's resellers, only Comeau ever really claimed full conformance).
 
oh, right, the infamous export
 
10:58 PM
@milleniumbug Yup--but you need correct 2-phase lookup to even begin working on export, and at the time gcc only sort of implemented it, and Clang wasn't in the game yet (and, of course, VC++ still hasn't implemented it correctly).
 

« first day (291 days earlier)      last day (2568 days later) »