Most active questions

13 votes
5 answers
599 views

How to return the results only when matching is true in R gsub()

I'm working with a character vector in R (test) where I need to extract specific parts of strings that match a pattern while discarding the original strings that don't match. My current solution is ...
JessicaLiu's user avatar
14 votes
3 answers
2k views

Why is it ok to cast to an undeclared struct pointer in C?

Why does this code compile? struct test is not even forward declared. int main(){ *(int*)((struct test*) 0x1234) = 0x0; return 0; }
Dan's user avatar
  • 3,038
13 votes
1 answer
1k views

Is it safe to catch stack overflows? Can it leave objects in messy/intermediate states?

I've been reviewing ways to kill threads in Java, and the overwhelming conclusion is that it is never safe to stop code at arbitrary points - doing so may leave resources in messy intermediate states. ...
Edward Peters's user avatar
8 votes
2 answers
3k views

React Native Expo + Firebase Auth: “Component auth has not been registered yet” on app launch

I’m building an Expo (SDK 53) React Native app with Firebase Authentication and I keep getting this error on startup: [runtime not ready]: Error: Component auth has not been registered yet, js engine: ...
Daveth's user avatar
  • 81
4 votes
2 answers
201 views

"Too many open files" after 1 month runtime [duplicate]

I have a Spring Boot app that checks for files every 10s. @Scheduled (fixedRateString = "10000") public void foo () { try { List <Path> ps = Files.list (Path.of (&...
chris01's user avatar
  • 12.6k
-3 votes
3 answers
182 views

Alternative to 'while(true) break' for sequential condition chain? [closed]

I have some code that uses a while(true) loop to ensure a sequence of conditions are met before performing an action. Any condition not met would break the sequence so the end action is not performed....
tuk's user avatar
  • 379
4 votes
5 answers
114 views

Assign a number for every matching value in list

I have a long list of items that I want to assign a number to that increases by one every time the value in the list changes. Basically I want to categorize the values in the list. It can be assumed ...
Regina Phalange's user avatar
11 votes
1 answer
513 views

MSVC calls wrong virtual method when storing a pointer to virtual method in a static inline variable

I'm encountering unexpected behavior on MSVC when storing a pointer to a virtual method in a static inline variable. The issue does not occur on GCC or Clang. Specifically, when I store a pointer to a ...
Artem Selivanov's user avatar
10 votes
1 answer
235 views

Why can this C++ code pass compile check? [duplicate]

I accidentally added a semicolon in an expression constructing std::string, but the compiler happily accepted it without complaining anything. I did a minimum reproducible example below, kindly teach ...
PkDrew's user avatar
  • 1,379
5 votes
1 answer
172 views

Assignment in (else) if statement triggers warning in MSVC but not in gcc / clang

This code snippet triggers a warning in MSVC (VS2022 17.10.2). int m = 0; if(int i = m) // ... else if (int i = m) // warning C4456: declaration of 'i' hides previous local declaration // ... ...
Lars's user avatar
  • 61
1 vote
4 answers
245 views

std::vector: when is a pointer not a pointer?

I have this existing working code, which I am trying to convert to implementation: Bitmap *pbitmap = new Bitmap(L"images.png"); nWidth = pbitmap->GetWidth(); nHeight = pbitmap->...
Gorlash's user avatar
  • 69
3 votes
2 answers
102 views

C++: `if constexpr` and `std::is_same_v` not working

I'm playing around with templates, compile-time evaluation and pointers to members. I don't understand why the following code doesn't set a.x to 42 and a.y to 3.14. According to the output, FieldType ...
md2perpe's user avatar
  • 3,113
20 votes
1 answer
1k views

CoreWCF stream continues to be written to after client disconnects

I have a very simple service class: using System.Diagnostics; var builder = WebApplication.CreateBuilder(); builder.Services.AddServiceModelServices(); builder.Services.AddServiceModelMetadata(); ...
Eterm's user avatar
  • 2,025
3 votes
3 answers
127 views

How do you convert a single surrogate character without a pair into its UTF-8 equivalent?

I am experimenting with wctomb in order to convert a wchar_t into its UTF-8 equivalent stored in a char[]. It works nicely, but not for surrogate characters ranging U+D800 to U+DFFF. int ret; // null-...
amegyoushi's user avatar
0 votes
2 answers
176 views

Invalid comparator in std::sort due to correct same result in both orders

I'm sorting a vector of structs, std::vector<DRIVE_OR_DIR>, where DRIVE_OR_DIR is defined as typedef struct { std::string path; boolean isDrive; } DRIVE_OR_DIR The idea is that elements ...
gene b.'s user avatar
  • 12.2k

15 30 50 per page
1
2 3 4 5
309