Talk:cpp/numeric/valarray
From cppreference.com
< Talk:cpp
One question about:
"Most C++ standard library implementations use expression templates to implement efficient operations on std::valarray, with rare exceptions ..."
Is this true (e.g. for MSVC)?
134.76.223.3 06:52, 10 August 2012 (PDT)
- Good question, I wrote most, but I only checked GNU's lihbstdc++ and LLVM's libc++. I don't have access to MSVC, but looks like IBM and Sun's libraries (based on Dinkumware and STLport, repesectively) return temporaries, for shame. Changed to be explicit on who implemented what. --Cubbi 08:07, 10 August 2012 (PDT)
[edit] Some suggestions on valarray pages
Pages about valarray seemed to be confused, because
- every Non-member functions says "applies the function std::xxx to each element of valarray". However, in its own page, "Unqualified function (xxx) is used to perform the computation".
- most of these non-member functions have a "Possible implementation" in their pages. But they look silly enough to manufacture due to nothing differences but functions' name. maybe using apply(xxx) to explain would be better?
- shall we replace return types of these member and non-member functions with /*see below*/ to highlight notes below?
- I like the /*see below*/ idea and won't object to "Applies the function cos to each element" as long as it still links to std::cos (which is the function 99.999% of uses will apply). Possible implementations are silly because they are not returning expression templates, but who is up to the task of writing up a realistic yet readable ET? --Cubbi (talk) 07:19, 11 November 2019 (PST)
So my suggestion is
- remove all possible implementations in those pages
- add "this function performs as if va.apply(xxx)" to every note which is generated by a template
- provide a silly possible implementation in apply's page with comments saying something like "ET can be used here"
By the way, I found it evident that more templates can be used in those pages.
Yaossg (talk) 21:22, 14 November 2019 (PST)
- Excessive template transclusion is deemed not a good idea. See Talk:Main_Page/Archive_2#Abandoning_complex_templates --D41D8CD98F (talk) 22:24, 14 November 2019 (PST)
- However, there are at least 15 pages owning exactly the same content with only their name different. any change to one of them may need to apply 14+ another times! This number is even larger than container's, whose pages are still using templates to build. Yaossg (talk) 00:09, 15 November 2019 (PST)
[edit] The Progress
Now I've applied some changes in apply and abs. What do you think about them? Shall I make further changes (including creating a new template metioned in abs)? Yaossg (talk) 21:33, 7 December 2019 (PST)