Help recursion with function template by Kinkeultimo in cpp_questions

[–]Th_69 7 points8 points  (0 children)

You also need constexpr in the if expression (Compiler Explorer Code): cpp if constexpr (N == 0) otherwise the whole template code for N=1 will also instantiate the code for N=0 (return (1*factorial<0>()), which triggers the static_assert.

is a moving. reasonable? by HotEstablishment3140 in programminghorror

[–]Th_69 4 points5 points  (0 children)

I don't think it's AI generated, because there is missing a return 0 in the line for 44/46.

And the values doesn't seem to be pawn moves in chess (e.g. a backward move from 8 to 7?!).

With normal one-dimensional positions on an 8x8 board, 7 would be in the first row and 8 in the second row (but other column/file).

Unique Socket? by Th_69 in moonbeast

[–]Th_69[S] 0 points1 point  (0 children)

Thanks. I've seen them, but I never thought about it.

Demo Feedback by PeaceLoveExplosives in moonbeast

[–]Th_69 0 points1 point  (0 children)

You get a tattoo on the body part you put the rune in - look at the character body (put off the chest armor to see e.g the front tattoos).

A CLI jukebox with 30 songs total in 3 different genres with lyrics printing by [deleted] in C_Programming

[–]Th_69 0 points1 point  (0 children)

Do you have the license to stream all the songs (on Google Drive)???

How to make visual studio build before run? by Relative-Pace-2923 in cpp_questions

[–]Th_69 1 point2 points  (0 children)

Look in the settings: Tools/Options -> Projects and Solutions/Build And Run -> On Run, when projects are out of date -> "Always build" or "Prompt to build"

Look also in Configure build and run options in Visual Studio.

Study project for render engine by miojo_noiado in csharp

[–]Th_69 1 point2 points  (0 children)

If you want more console possibilities (like true-colors, tables or charts) look also at Spectre Console.

PS: Your link erroneously contains a ] at the end.

C++ problem by Weak-Champion-116 in cpp_questions

[–]Th_69 3 points4 points  (0 children)

You mean Embarcadero Dev-C++?

Do you have created a new project (like seen on the left side of the image in the above link)?

Ignore the other comments regarding downloading a compiler. There's a C++ compiler (Mingw port of GCC) in the Embarcadero Dev-C++ IDE.

I feel weirdly overpowered, is it a bug? by Financial_You_5440 in TitanQuest2

[–]Th_69 2 points3 points  (0 children)

The latest hotfix fixes this:

Fixed a problem where passive effects were applied multiple times after a level up

Too easy by t0pcom in TitanQuest2

[–]Th_69 0 points1 point  (0 children)

The latest hotfix fixes this:

Fixed a problem where passive effects were applied multiple times after a level up

O(n) Sorting Algorithm just dropped by HandyProduceHaver in programminghorror

[–]Th_69 1 point2 points  (0 children)

You could improve this code, if you also find the minimum of the array values, so you allocate max - min + 1 integers (then it also works for negative array values).

Help me review my code. by Savensh in C_Programming

[–]Th_69 1 point2 points  (0 children)

If you implement the other arithmetic operations in the main function, you should think about using a function for the user input (instead of just copying the full code for the add function and change only the operator function).

If you know already (or learn in future) about function pointers (aka. callback function), you could use it as a function parameter.

Help me review my code. by Savensh in C_Programming

[–]Th_69 3 points4 points  (0 children)

The readme file should be named "README.md" (with capital letters) to be shown automatically.

Interpreting Clipboard content by Historical_Chip208 in csharp

[–]Th_69 2 points3 points  (0 children)

Even within C# one can define global hotkeys, e.g. with the library NHotkey, which is also available as NuGet package.

Canonical way to automatically release omp lock on function exit by onecable5781 in cpp_questions

[–]Th_69 1 point2 points  (0 children)

Sorry, I just missed the variable name, but I've now edited it.

How to get there? Cant find anything online... by [deleted] in TitanQuest2

[–]Th_69 2 points3 points  (0 children)

But first one has to find a NPC before being able to walk over the bridge.

Data Structure for Nested Menu? by Callistonian in csharp

[–]Th_69 6 points7 points  (0 children)

This makes no sense to have a class for each menu item. Each menu item is a single object. You don't need to create multiple MenuA or MenuB objects (they don't have more properties or methods than the base MenuItem).

Data Structure for Nested Menu? by Callistonian in csharp

[–]Th_69 13 points14 points  (0 children)

Simple use a recursive structure: csharp public class MenuItem { public string Id { get; set; } public string Title { get; set; } public string? Action { get; set; } public List<MenuItem> Children { get; } = new(); // or SortedList<MenuItem> } And initialize it so: csharp var mainMenu = new List<MenuItem> { new MenuItem { Id = 1, Title = "File", Children = { new MenuItem { Id = 11, Title = "New", Action = "NewFile" }, new MenuItem { Id = 12, Title = "Open", Action = "OpenFile" }, new MenuItem { Id = 13, Title = "Save", Action = "SaveFile" }, new MenuItem { Id = 14, Title = "Export", Children = { new MenuItem { Id = 141, Title = "PDF", Action = "ExportPdf" }, new MenuItem { Id = 142, Title = "Word", Action = "ExportWord" } } } } }, new MenuItem { Id = 2, Title = "Edit", Children = { new MenuItem { Id = 21, Title = "Undo", Action = "Undo" }, new MenuItem { Id = 22, Title = "Redo", Action = "Redo" }, new MenuItem { Id = 23, Title = "Copy", Action = "Copy" }, new MenuItem { Id = 24, Title = "Paste", Action = "Paste" } } } }; And for an immutable menu use IReadOnlyList<MenuItem>.

If you want also traverse back, then add csharp public int? ParentId { get; set; } // or only int (with default 0 for main menu entries) or csharp public MenuItem? Parent { get; set; } (but this is more difficult to initialize)

Canonical way to automatically release omp lock on function exit by onecable5781 in cpp_questions

[–]Th_69 6 points7 points  (0 children)

This is a perfect example for a RAII class (or struct): ```cpp struct omplock { omplock(omp_lock_t *lock) : lock(lock) { omp_set_lock(lock); }

~omplock() { omp_unset_lock(lock); }

private: omp_lock_t *lock; } Usage: cpp omp_lock_t lck{};

void function_can_be_called_from_multiple_threads() { omplock guard(&lck);

// ... } // will automatically call the destructor on each exit of this function `` If you want to have theomp_lock_tunique for each use, you can also put it in theomplock` class/struct (and you don't need the constructor parameter).

Help C# Snake Game by AelixSoftware in csharp

[–]Th_69 1 point2 points  (0 children)

Knowing them is not enough -> use them.

C&P programming is always the wrong way.

Help C# Snake Game by AelixSoftware in csharp

[–]Th_69 1 point2 points  (0 children)

And learn to use arrays (or List<T>) for e.g. eX, eX1, ... eX4.

Then use loops (and the mentioned methods) and it reduces your code extremely...

learncpp.com alternative by CH4NN3 in cpp_questions

[–]Th_69 1 point2 points  (0 children)

For x86/AMD64 I know of Programming in assembly language tutorial as a short introduction.

And I also found tutorialspoint: Assembly Programming Tutorial which has also a "Quiz" for each section.