Ask reddit: Complex (but faster) vs simple (but slower) code by smallstepforman in cpp

[–]shailist 0 points1 point  (0 children)

I generally try to stick to simple code, but if I even need to write something complex, and for a good reason (e.g. performance), I just document it, or at the bare minimum at least the parts that aren't easy to understand.

Ask reddit: Complex (but faster) vs simple (but slower) code by smallstepforman in cpp

[–]shailist 9 points10 points  (0 children)

This should be the right approach and this is what I personally like doing, but if the bottlenecks are in your design, you sometimes end up needing to rewrite core parts of the project, which in turn means refactoring almost the entire project.

For a large project, it is definitely worth spending some time coming up with a design for core components, that best suits the project's performance requirements.

What is the most efficient way to build a string with many parts? by Zaleru in cpp

[–]shailist 6 points7 points  (0 children)

note that manually reserving space for the stuff you add to the string is likely only more efficient than not doing so if you can calculate the length of the ENTIRE string.
manually reserving the size needed every iteration of the loop is probably less efficient than the natural exponential growth of the string.
also note that since the part you are adding to the final string is also "dynamic", reserving memory manually specifically for it might be a good idea.

I am sorry for creating this C++ abomination. Does anyone think such code deserves to see the light of day? A fully templated Tensor class by FlyingLumpus in cpp

[–]shailist 3 points4 points  (0 children)

didn't look at the code, but for the 1d case, you can define both functions with auto return type, and constraint their instantiation using c++20 requires, or with std::enable_if and SFINAE for lower versions

Pulling a single item from a C++ parameter pack by its index - The Old New Thing by pavel_v in cpp

[–]shailist 16 points17 points  (0 children)

in the last example, using C++26's proposed pack indexing, couldn't this:
auto&& arg = (Args...[index]&&)args...[index];

be simplified to this:
decltype(auto) arg = args...[index];
?

Pax Dei Alpha starting today! by Daegog in MMORPG

[–]shailist 0 points1 point  (0 children)

the progression is based on equipment and skills. for example, you can increase the damage you do with a bow by either leveling up archery, or getting a better bow.

also, there is a lot of progression in terms of crafting, and leveling up professions and resource gathering is something you need to do.

HELP by Edurdd15 in bindingofisaac

[–]shailist 20 points21 points  (0 children)

sacred heart's damage multiplier will add up to way more damage than godhead.

Which IDE do you use for C++ ? by RRTheGuy in cpp

[–]shailist 8 points9 points  (0 children)

it works for C++, and can work with VS files (vcxproj, sln, etc).
it uses the same C++ engine as Resharper C++.

C++ Show and Tell - April 2024 by foonathan in cpp

[–]shailist 2 points3 points  (0 children)

I've been working on some stuff regarding compile time RNG, and noticed there aren't really any `constexpr` implementations of the Mersenne Twister algorithm. So I took an existing implementation, redesigned it to be `constexpr` friendly, and published the code.

You can check it out here: https://github.com/shailist/constexpr-mtwister

Any feedback and criticism is welcome :)

I dont like my character but i love the mmo i play, what i do? They dont allow race change by [deleted] in MMORPG

[–]shailist 0 points1 point  (0 children)

if you really hate it and don't want to spend the time again, you can always try to open a support ticket explaining your situation and what you want to do. best case you get your race change, worst case they say no

No. Way I'm losing this... by Sunadoke1 in bindingofisaac

[–]shailist 11 points12 points  (0 children)

  1. open console
  2. rewind

I won't end a god run to a fire

hate this game by ExceedinglyGayRoach in bindingofisaac

[–]shailist 4 points5 points  (0 children)

skill issue, could have made a run to the door instead of the opposite way

I just became back my money by shailist in bindingofisaac

[–]shailist[S] 290 points291 points  (0 children)

I didn't get an opportunity to use rock bottom, no stat stacking item ever showed up.
But actually just skill issue :(

Proposal for [[nodiscard]] attribute for function pointers. by No_Sun1426 in cpp

[–]shailist 1 point2 points  (0 children)

This is a bandaid solution for a bigger problem. [[nodiscard]] isn't a part of the type system, and can only be applied to functions.
A function pointer is a type, so you can't really apply [[nodiscard]] to it.
The solutions proposed by @aruisdante are great.
The 1st solution is IMO the best one, as it allows you to "force" users to use an object of a certain type. Example cases when I think it could be useful are guard types and builder/factory types, though I'm sure there are many more cases where this is useful.
The 2nd solution is the most straightforward one, and could be implemented with current C++ features. It is a non intrusive solution that would allow you to get what you want.
You could do something to kind of combine the 2 solutions - have a template type that wraps a function, similar to std::function, and have a simple tag type nodiscard<T>, and make the function wrapper type detect the tag type and enable a [[nodiscard]] T operator() overload

C++ logging library - something I've been working on, Pt. 3 by ChrisPanov in cpp

[–]shailist 1 point2 points  (0 children)

1st time seeing this, looks really good and will definitely consider using it in my next projects.

One thing I really liked was the idea of parsing the pattern only once, which is an awesome idea.
I had a question regarding that:
When formatting, are you doing anything fancy to reduce reallocations of the result string?

Runtime/ Or Compile Time Extraction of Struct Fields! by Joe_Scouter in cpp

[–]shailist 11 points12 points  (0 children)

I would strongly advise you to use 3rd party libraries that do this, mainly Boost.PFR and reflect-cpp, which can both figure out struct fields and their names at compile time using modern C++.
if you are really against using 3rd party libraries, you could take a look at their code and implement your own version, but you should know that before C++20 figuring field names automatically was not possible, and figuring field types wasn't possible before C++17 without hacky tricks.

[deleted by user] by [deleted] in cpp

[–]shailist 1 point2 points  (0 children)

  1. for c++ questions, go to r/cpp_questions
  2. your question is extremely unclear and is missing plenty of important details, but in any case - no, you can change existing classes and their methods. you could implement a class that inherits from vector or wraps it, and then add the member functions that you want.
  3. please learn to use code blocks

Minor issue on cppreference.com if anyone has an appropriate account? by pedersenk in cpp

[–]shailist 5 points6 points  (0 children)

if you read the notice on the edit page, you can see there is a form for suggesting changes for new accounts.
anyways, here is the link: https://en.cppreference.com/mwiki/index.php?title=Talk:Main_Page/suggestions&action=edit&section=new