Tag: c#
-
What is the purpose of _t aliases and _v variable templates for type traits?
7 There are a lot of *_v and *_t suffixes, like std::is_same_v, std::invoke_result_t, result_of_t and milions of other such functions. Why do they exist at all? Is it beneficial in any context to expose implementation details like std::result_of::type or std::is_same::value? Ignoring standard compliance, should the _v _t versions always be preferred? Could the ::type ::value…
-
GraphQL disposed DataContext
0 When trying GraphQL in the Playground, I get the following error: Cannot access a disposed context instance. A common cause of this error is disposing a context instance that was resolved from dependency injection and then later trying to use the same context instance elsewhere in your application. This may occur if you are…
-
System.Text.Json Deserialize doesn’t work for a GraphQL response
0 I am working on a .NET 6 application using GraphQL and System.Text.Json. For the a shared util function: public async Task<GraphQlResponse<T>> Query<T>(string mutation, IQueryInput variables = null) { var content = JsonSerializer.Serialize(new { query = mutation, variables = (object) variables }); var request = new HttpRequestMessage { Method = HttpMethod.Post, RequestUri = new Uri(baseUrl),…
-
C++23: char now supports Unicode?
8 Does C++23 now provide support for Unicode characters in its basic char type, and to what degree? So on cppreference for character literals, a character literal: ‘c-char’ is defined as either: a basic-c-char an escape sequence, as defined in escape sequences a universal character name, as defined in escape sequences and then for basic-c-char,…
-
If arrays are passed by reference why should i use int(&)[]
9 #include <iostream> using namespace std; void Change(int arr[3]) { for (int i = 0; i < 3; i++) { arr[i] = 1; } } int Test() { int arr[3] = { 0, 0, 0 }; for (int i = 0; i < 3; i++) { cout << arr[i] << endl; } Change(arr); for (int…
-
GraphQL HotChocolate file upload
0 How can I make a mutation call from a client and upload a file? I can do it in the editor (screen) But I cannot figure out how to make the same from a client var request = new GraphQLRequest { Query = query, Variables = new { id = "id" }, }; var…
-
Why is there no parallel `std::accumulate` in the C++ standard?
7 I think it is confusing that there is no parallel version of std::accumulate in the C++ standard. It appears to me that it would be trivial to implement it in parallel, for instance, based on OpenMP or SIMD instructions. Does anybody have a good explanation for why the standard committee chose to introduce a…
-
Linux memcpy restrict keyword syntax
9 I know that the restrict qualifier in C specifies that the memory region pointed by two pointers should not overlap. It was my understanding that the Linux (not SUS) prototype for memcpy looks like – void* memcpy(void *restrict dest, const void *restrict src, size_t count); However, when I looked at man7.org/memcpy it seems that…
-
What happens when an assumption, i.e. [[assume]] contains UB?
6 In C++23, the [[assume(expression)]] attribute makes it so that if expression is false, the behavior is undefined. For example: int div(int x, int y) { [[assume(y == 1)]]; return x / y; } This compiles to the same code as if y was always 1. div(int, int): mov eax, edi ret However, what happens…
-
How to fix code to avoid warning -Wunsafe-buffer-usage
6 Before clang 16.0 I was able to compile all my projects using -Weveything without problems, fixing my code and paying attention to the (useful) warnings that this option gave. However, it seems that the -Wunsafe-buffer-usage was added in version 16 (my system updated to it recently) and then compiling any project is impossible without…