Tag: c#
-
Why do static lambda’s (c# 9) still have a target?
7 Static lambda’s introduced in c# 9 allow us to mark a lambda expression as static to prevent it from capturing instance state. However when you check the .Target property on the lamda it is still set, which is different to when you set an Action to a static method which has no target. Action…
-
GraphQL Best Practise API Communication
0 I have an .Net Application which uses a graphQL API for some business logic. The schema is really big and so are the queries. I auto generated the graphql schema into c# classes which worked really well. But my Queries are equally big and I dont know how to store or build them besides…
-
C++20’s std::views::filter not filtering the view correctly
7 I was writing a simple C++ program that generates a list of random integer values from a normal distribution, then takes first N generated items and filters them so that their absolute value is greater than 42. The code i wrote is the following: int main() { //convenience namespace rng = std::ranges; namespace view…
-
Why the following graphql schema does not compile with HotChocolate?
0 I’m trying to put together a more complex stuff than Getting started guide with HotChocolate and I hit a wall, and the documentation does not help. I have multiple questions: What I’m doing wrong here? I went through all the examples they have and it seems I’m doing the right thing, but the error…
-
Why is ‘char -> int’ promotion, but ‘char -> short’ is conversion (but not promotion)?
22 I’ve read cppreference.com’s implicit conversion: Integral promotion: prvalues of small integral types (such as char) may be converted to prvalues of larger integral types (such as int). […] Note that all other conversions are not promotions; for example, overload resolution chooses char -> int (promotion) over char -> short (conversion). The conversion from char…
-
Why don’t free functions in implementation files have internal linkage by default?
15 When it comes to functions (non-member functions in C++), marking them as static gives them internal linkage. This means that they are not visible outside the translation unit. Why isn’t this the default? I don’t have a good statistic but from what I’ve seen most functions in implementation files should be marked as static.…
-
Logical vs. bitwise operators. Both are wrong?
11 When I use the following minimal code in an c++ ConsoleApp in VS2019, I get two warnings, which are completely opposite. int main() { unsigned char op1 = 0x1; unsigned char op2 = 0x3; unsigned char result1 = op1 | op2; unsigned char result2 = op1 || op2; } The warning at unsigned char…
-
C++20 use concept to restrict an ‘auto’ non-type template argument?
9 I have a template class taking several non-type arguments (GPIO descriptors). Auto is used to allow several different GPIO implementations to be used. These implementations can’t derive from a common base class. Can I use a concept to restrict these arguments to ones with the right interface? I got a concept but it’s not…
-
Benefit of endless-loops without side effects in C++ being undefined behavior compared to C?
28 In C++ loops as for(;;) {} are undefined behavior, whereas they are not in C(?). On P2809R0. Trivial infinite loops are not Undefined Behavior, it is expressed that there are good reasons for doing so. Are there any simple examples to make that clear? c++ c loops optimization undefined-behavior Share Improve this question Follow…