hkaiser changed the topic of #ste||ar to: STE||AR: Systems Technology, Emergent Parallelism, and Algorithm Research | stellar-group.org | HPX: A cure for performance impaired parallel applications | github.com/STEllAR-GROUP/hpx | This channel is logged: irclog.cct.lsu.edu
<gonidelis[m]>
hkaiser: so std::forward<T> forces the move constructor because it ....?
<gonidelis[m]>
it casts to an rvalue ref?
<hkaiser>
gonidelis[m]: no
<gonidelis[m]>
that's what move does :)
<hkaiser>
std::forward is needed as T is a universal (forwarding) reference
<hkaiser>
std::forward casts as well, just not always
<gonidelis[m]>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
<gonidelis[m]>
hkaiser: that's it!
<hkaiser>
let's take an hour tomorrow to talk about move sematics
<gonidelis[m]>
rtohid: random ref
K-ballo has quit [*.net *.split]
K-ballo has joined #ste||ar
<gonidelis[m]>
hkaiser: i remember last year you taught me how std::move is being used on universal references to facilitate both rvalue refs and const refs..... isn't that right?
<gonidelis[m]>
and if it is, what is the usage of std::move/std::forward outside of tamplates?
<hkaiser>
gonidelis[m]: move is used for rvalue refs, forward for universal refs
<hkaiser>
move can be used outside of templates, it deals with rvalue refs, forward makes sense for templates only (i.e. universal refs)
<K-ballo>
gonidelis[m]: you're certainly allowed to use a variable after move
<K-ballo>
all the invariants of the object still hold
<K-ballo>
you wouldn't be allowed to call `vect[0]` after move because [0] has a size() > 0 precondition,
<K-ballo>
but you are allowed to call size() since it has no preconditions, and if that returns > 0 then you can call [0]
<K-ballo>
you should not however expect `vect[0]` to return 1 in that case
<K-ballo>
in the specific case of `std::vector` the moved from thing is guaranteed empty.. (types can always offer stronger guarantees on their moved from state)
K-ballo has quit [Quit: K-ballo]
K-ballo has joined #ste||ar
K-ballo1 has joined #ste||ar
K-ballo has quit [Ping timeout: 264 seconds]
K-ballo1 is now known as K-ballo
hkaiser has joined #ste||ar
hkaiser has quit [Quit: Bye!]
<gonidelis[m]>
K-ballo: why is the move_to guaranteed empty?
<gonidelis[m]>
thanks btw
rori[m]1 has joined #ste||ar
<K-ballo>
because the standard says so
<gonidelis[m]>
it does not have the contents of vect?
<K-ballo>
it's impossible given the spec and the allocator requirements to end up with two chunks of memory
<K-ballo>
it's never guaranteed to have the original contents after move
<K-ballo>
if it were any other container, it could have the original elements, it could be empty, or it could have new elements different from before
<K-ballo>
for example, if you move an std::array you end up with an array of moved from values
<K-ballo>
if you move a small string with embedded storage, you could end up with the original string still embedded
<K-ballo>
the important thing is that the moved object is in some valid state
<K-ballo>
you don't know which state unless the spec gives you extra guarantees, but you can always ask the object
<K-ballo>
a moved from shared_ptr is always empty, guaranteed, for example
<gonidelis[m]>
gotcha
<gonidelis[m]>
alright
<gonidelis[m]>
so if itry to access its elements after moving it i ll find gibberish?
<gonidelis[m]>
K-ballo: 👆️
<K-ballo>
UB unless you first check that the container has at least as many elements
<gonidelis[m]>
cool
hkaiser has joined #ste||ar
Yorlik has quit [Read error: Connection reset by peer]
<dkaratza[m]>
can sb explain what does scoped_annotation do?
<hkaiser>
dkaratza[m]: it associates a 'name' with a section of code
<hkaiser>
that allows to visualize code execution in some tools (vtune, apex, etc.)
<hkaiser>
helps with analysing performance and figure out what piece of code is responsible for slowdowns, etc.
<dkaratza[m]>
<hkaiser> "dkaratza: it associates a 'name'..." <- I see, great! thank you!
<gonidelis[m]>
hkaiser: so the `if(NOT MSVC)`s are basically of no use now?
<gonidelis[m]>
is this the equivalent: `(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" AND "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC"))`, doesn't feel liek it