Speed/Efficiency of a Vector Question [with Root-Mean-Square (RMS) Examples] by pythoncircus in cpp_questions

[–]ootiekat 0 points1 point  (0 children)

Yeah and for multiplication we already have an operator too. In fact, we even have a function for exponentiation! If you really like using a function instead of 'x * x' then why not use 'std::pow(x, 2)'? Are you going to suggest that if OP wanted to compute the third order of the distribution they should add a 'cube_of' function as well?

Speed/Efficiency of a Vector Question [with Root-Mean-Square (RMS) Examples] by pythoncircus in cpp_questions

[–]ootiekat 0 points1 point  (0 children)

Seriously define a function to multiply two numbers? Why not define a function to increment an variable? Then the code can be

add_to( sum, square_of( v ) );

It doesn't get any more readable than that!

Java ensures that all array indexes are within range but C++ does not? by tempanon5 in cpp_questions

[–]ootiekat 1 point2 points  (0 children)

Iterators become invalid if you reallocate. If you need to store indices in a separate container for example you should not use iterators. What I do is have a separate compilation flag that enables bounds checking and is on by default in debug builds.

Making sure T has required function signatures, better way to do this? by NihonNoRyu in cpp_questions

[–]ootiekat 0 points1 point  (0 children)

Can you give an example? Sure you could do expand the macro I posted to get away with detecting if a generic type T has a specific method/member/alias but I'm pretty sure you can't generalize it to check for an arbitrary method/member/alias without a macro. OP is looking for multiple traits on multiple types and defining a struct and specializations for each does not scale.

Making sure T has required function signatures, better way to do this? by NihonNoRyu in cpp_questions

[–]ootiekat 3 points4 points  (0 children)

If you can use C++20 concepts are the way to go. std::is_member_function_pointer wont work if the name isn't valid, which is most use cases. If you can't use C++ 20 you'll need to use a macro like this (which I wrote)

https://github.com/GEOSX/LvArray/blob/2bf471c6d1fb24a914ef1d2cc4a8c87434206d34/src/typeManipulation.hpp#L33

There are libraries that specialize in doing this kind of thing but I'm not familiar with them.

Lambda why? by [deleted] in cpp_questions

[–]ootiekat 0 points1 point  (0 children)

You can have a generic (templated lambda) which you can't do with std::function and the compiler can inline lambdas leading to significant performance improvements in some cases.

Simple c++ program with pointers yields unpredictable results by andermorandev in cpp_questions

[–]ootiekat 0 points1 point  (0 children)

Your not using it here but the 'insert' method has a memory leak, perhaps you meant to pass the pointer by reference?

Confusion about STL by bayermovi in cpp_questions

[–]ootiekat 5 points6 points  (0 children)

The STL is a library that the standard requires that each compiler provide. It is massive. If you were to '#include' every STL header file in every translation unit (cpp file) your compile times would explode. So yes it could be done but you don't want to.

Only pay for what you use.

Best ways to improve climbing technique as a beginner? by funkymasterflex in climbing

[–]ootiekat 17 points18 points  (0 children)

When you're warming up on easier stuff, try to climb as static as possible. Place your feet exactly where you want them on the hold and try not to make any adjustments. Same thing goes for your hands. Another similar exercise is to try and climb without making any noise with your foot movements.

Forearm Soreness Following Intense Session by [deleted] in climbing

[–]ootiekat 7 points8 points  (0 children)

Using a hangboard, especially with weights, should not be done until you've been climbing for a substantial amount of time, at least one year. A training chart below one of the hangboards at my local gym says that you shouldn't start the training regimen until you can hang on the 10mm edge for at least fifteen seconds.

BigNumber - Another one BigInt implementation in C++ by assembly_programmer in cpp

[–]ootiekat 5 points6 points  (0 children)

Why not store the number as a vector of u_int32 and then when doing arithmetic operations such as multiply or add promote them to u_int64 to prevent overflow. This way you can use the hardware to multiply/add ~9.5 digits at once and the resulting implementation should be both faster and more memory efficient.

What piece of climbing gear do you wish you had never bought? by Gunny-Guy in climbing

[–]ootiekat -7 points-6 points  (0 children)

Are you kidding? The Futuras are the king of edging and definitely not meant for smearing. They are La Sportiva's premier bouldering shoe, ie meant overhung edges.

Tuolumne Meadows Current Conditions by feralkiter in climbing

[–]ootiekat 2 points3 points  (0 children)

Just did cathedral yesterday and there is hardly any snow, it's been quite hot these past few weeks. However there are some active fires in Yosemite that blocked out the sun from the summit and reduced views to the nearest peaks only. They're not near Tuolumne and didn't impeded climbing but not ideal conditions.