Related
Martin Why should calling std::ref be preferred over not calling it at all? template<class F, class...Ts> F for_each_arg(F f, Ts&&...a) {
return (void)initializer_list<int>{(ref(f)((Ts&&)a), 0)...}, f;
// why not return (void)initializer_list<int>{(f((Ts&&
Martin Why should calling std::ref be preferred over not calling it at all? template<class F, class...Ts> F for_each_arg(F f, Ts&&...a) {
return (void)initializer_list<int>{(ref(f)((Ts&&)a), 0)...}, f;
// why not return (void)initializer_list<int>{(f((Ts&&
Martin Why should calling std::ref be preferred over not calling it at all? template<class F, class...Ts> F for_each_arg(F f, Ts&&...a) {
return (void)initializer_list<int>{(ref(f)((Ts&&)a), 0)...}, f;
// why not return (void)initializer_list<int>{(f((Ts&&
allyourcode: I've read the first few sections of PEP 3107, but I still don't understand their benefits to the language. It seems to me that you can use a decorator to add metadata to a function. E.g def returns(return_type):
f.return_type = return_type # <-
allyourcode: I've read the first few sections of PEP 3107, but I still don't understand their benefits to the language. It seems to me that you can use a decorator to add metadata to a function. E.g def returns(return_type):
f.return_type = return_type # <-
Kevin King333 I used to create a thread this way std::thread(&A::Func, this);
But I found that there is another way std::thread(&A::Func, std::ref(*this));
What is the difference between them? Carles In the context of starting a thread running a class member
ignorance I'm reading an article by Herb Sutter about passing smart pointers to functions. He didn't mention it std::weak_ptr, and honestly, I couldn't find a good scheme to pass such a smart pointer. Does the function have ownership? pass std::shared_ptr. Doe
Ikichi I see a code snippet in use and am not sure about the availability of this feature.make_ref() hexdocs says: Returns almost unique references. The returned reference will reappear after about 2^82 calls; thus, it's unique enough for practical use. Inline
Ikichi I see a code snippet in use and am not sure about the availability of this feature.make_ref() hexdocs says: Returns almost unique references. The returned reference will reappear after about 2^82 calls; thus, it's unique enough for practical use. Inline
new version While reading http://en.cppreference.com/w/cpp/language/member_functions I came across something but never seen before: lvalue/rvalue Ref-qualified member functions. What is their purpose? kakaria Just read below: During overload resolution, if a n
Ikichi I see a code snippet in use and am not sure about the availability of this feature.make_ref() hexdocs says: Returns almost unique references. The returned reference will reappear after about 2^82 calls; thus, it's unique enough for practical use. Inline
arr_sea It seems that introduced Eigen::Ref<>in Eigen 3.2, std::reference_wrapper<>introduced in C++11 achieves a very similar goal. Obviously, Eigen::Ref<>C++11 dependencies won't be introduced like std::reference_wrapper<>, but what else should be considered
Arun Wood Is there any way to take advantage of ref-qualified member functions std::mem_fn? The following code fails to compile: class DeadPool {
public:
void jump() & {
std::cout << "Did not jump\n";
}
void jump() && {
std::cout << "Jumped from
Van Van Heuvel Consider the following template function that takes a callable, evaluates it, and returns the result (for illustration purposes only): template<typename F, typename... A>
auto evaluate(F&& f, A&&... args) -> decltype(f(std::forward<A>(args)...))
Ralph Tandetzky: What is the semantic difference between writing expressions std::tie( x, y, z )
and the following expression? std::make_tuple( std::ref(x), std::ref(y), std::ref(z) )
If so, what is the difference? By the way, how is this question different
Ralph Tandetzky: What is the semantic difference between writing expressions std::tie( x, y, z )
and the following expression? std::make_tuple( std::ref(x), std::ref(y), std::ref(z) )
If so, what is the difference? By the way, how is this question different
Ralph Tandetzky Is there any semantic difference between writing expressions std::tie( x, y, z )
and the following expression? std::make_tuple( std::ref(x), std::ref(y), std::ref(z) )
If so, what is the difference? By the way, what is the difference between
Ralph Tandetzky: What is the semantic difference between writing expressions std::tie( x, y, z )
and the following expression? std::make_tuple( std::ref(x), std::ref(y), std::ref(z) )
If so, what is the difference? By the way, how is this question different
Ivan Kush std::invokeWhy do we need it when we already have it std::function? What is the difference between them? Both are used to invoke callable objects. What's the point of adding a new template? Jesper Juhl std::invokeis a generic way to activate any call
Gabriel I'm looking at the std::functionimplementation and its invocationoperator() template<typename Ret, typename... ArgTypes>
Ret function< Ret (ArgTypes...)>::operator()(ArgTypes...args) const
{
// some stuff
return invoker(functor, std::forward<ArgTyp
Ivan Kush std::invokeWhy do we need it when we already have it std::function? What is the difference between them? Both are used to invoke callable objects. What's the point of adding a new template? Jesper Juhl std::invokeis a generic way to activate any call
Ivan Kush std::invokeWhy do we need it when we already have it std::function? What is the difference between them? Both are used to invoke callable objects. What's the point of adding a new template? Jesper Juhl std::invokeis a generic way to activate any call
Gabriel I'm looking at the std::functionimplementation and its invocationoperator() template<typename Ret, typename... ArgTypes>
Ret function< Ret (ArgTypes...)>::operator()(ArgTypes...args) const
{
// some stuff
return invoker(functor, std::forward<ArgTyp
Gabriel I'm looking at the std::functionimplementation and its invocationoperator() template<typename Ret, typename... ArgTypes>
Ret function< Ret (ArgTypes...)>::operator()(ArgTypes...args) const
{
// some stuff
return invoker(functor, std::forward<ArgTyp
Ivan Kush std::invokeWhy do we need it when we already have it std::function? What is the difference between them? Both are used to invoke callable objects. What's the point of adding a new template? Jesper Juhl std::invokeis a generic way to activate any call
Ivan Kush std::invokeWhy do we need it when we already have it std::function? What is the difference between them? Both are used to invoke callable objects. What's the point of adding a new template? Jesper Juhl std::invokeis a generic way to activate any call
Gabriel I'm looking at the std::functionimplementation and its invocationoperator() template<typename Ret, typename... ArgTypes>
Ret function< Ret (ArgTypes...)>::operator()(ArgTypes...args) const
{
// some stuff
return invoker(functor, std::forward<ArgTyp
Gabriel I'm looking at the std::functionimplementation and its invocationoperator() template<typename Ret, typename... ArgTypes>
Ret function< Ret (ArgTypes...)>::operator()(ArgTypes...args) const
{
// some stuff
return invoker(functor, std::forward<ArgTyp
Nicu Stiurca I am using the <complex> C++ header, and need to know the range of the std::arg function which returns the phase angle of a complex number. Ie, is it [-pi, pi], [0, 2*pi], or something else? Is there a guarantee about the range in the standard? AF