« first day (1136 days earlier)      last day (1699 days later) » 

11:05 AM
Could I take address of a std::optional::value(), when I'm sure it has_value()? Can I use this address to assign other values into the value contained in the optional object?
 
 
4 hours later…
2:58 PM
@JerryCoffin Thanks
@adamaero What do you mean the code doesn't compile? It does.
 
Sounded like it didn't.
 
@adamaero Why? And you don't need to rely on what something sounds like, there's a link there so you can check if it compiles or not.
 
Yep.
 
3:28 PM
Is anybody familiar with a way to get the mangled name of a member function as it appears in the shared object? I feel like typeid().name() is the way to go, but somehow its slightly different :/
e.g. typeid( static_cast<bool (X::*)(string)>(X::put) ).name() gets reasonably close but not quite
 
That's all implementation defined and I doubt you'd get any guarantee that it'll work in general. The type wouldn't include the "put" in any case if you're using typeid
 
Does not have to be general, I can rely on all involved libraries be compiled with the same compiler. put is an overloaded member function i need to get resolved.. how can I get away without including that? :/
 
I'd just say use some library that does the name mangling, there's no good tools by default and definately nothing in the standard
 
4:37 PM
quite an irony that there is no convienient way to get that from the compiler at copmiler time, your were right about the put being purged, as it becomes a generic X:: function pointer -.-
 
5:35 PM
Guys do you know how to do thread safe one-time initialization of a pointer in Windows? I wanted to use std::mutex or std::atomic, but I'm working in a situation where CRT might not be initialized yet (dll injected into a process created with CREATE_SUSPENDED flag), so I guess it's better to use only native APIs (yeah, I just crashed the injected process because I used std::stringstream to parse some data...)
 
 
2 hours later…
7:41 PM
I declared my queue as such queue<pair<int, unordered_map<int, int>&>>Queue;
but when I go to push my values in Queue.push(make_pair(17, &sets )); I get an error
Line 30: Char 33: error: no matching function for call to 'std::queue<std::pair<int, std::unordered_map<int, int>&> >::push(<brace-enclosed initializer list>)'
Queue.push({17, &sets });
^
 
@Rick references aren't copyable IIRC?
 
I'm not trying to copy just pass it as an instance
 
so there is no way to do a move in a queue
 
queue is just an adapter, the underlying container must support it
 
7:51 PM
I am using a pair
 
do you need pair?
 
to pair the values, yes, but pair as a container is not strictly necessary
 
pqueue actually uses pair
but queue doesn't
you could just use a POD
 
by the way pair works just fine in the queue, it's the unordered_map, which is being copied that's the problem
maybe a map might be a better container to avoid copying?
or a vector
 
dunno what you're using it for
 
7:59 PM
I need to be able to pass the unordered_map to nodes I encounter without copying, so all carry a reference to the same unordered_map
 
8:16 PM
so it turns out make_pair elides references
 
 
2 hours later…
10:30 PM
@Mgetz Thanks!
 
 
1 hour later…
11:39 PM
Just curious, I know the following is thread safe since C++11 in the sense that constructor will only be executed once:
Type& function() {
    static Type type;
    return type;
}
But what about this? is the code below thread safe as well?
Type& function() {
    static Type type = someOtherFunction();
    return type;
}
 
Yes, someOtherFunction() will be executed only once.
 

« first day (1136 days earlier)      last day (1699 days later) »