Skip to main content
0 votes
1 answer
33 views

I maintain a library, let's call it libfoo, using CMake as a build system generator. I've made my library usable via FetchContent_MakeAvailable() (although I dislike that interface), e.g. by prefixing ...
einpoklum's user avatar
  • 140k
1 vote
1 answer
71 views

In a project I'm working on, I need to determine which libc is being used, for reasons. I know that, on current Linux systems, I can usually write: $(gcc --print-library=libc.so.6) | head -1 and get ...
einpoklum's user avatar
  • 140k
5 votes
2 answers
411 views

In my code, I have something like: try { do_stuff(); } catch(my_exception_class& e) { if (not can_ignore_exception(e)) { throw e; } log_or_do_nothing(e); } A static analyzer (...
einpoklum's user avatar
  • 140k
Best practices
10 votes
29 replies
8k views

I'm moving from C to C++ and I'm trying to avoid using C practices in C++. It is said that raw pointers are a C feature, and that in C++ I should use smart pointers instead, yet every example I have ...
noname noname's user avatar
1 vote
1 answer
85 views

If i would compare by references i can deal with raw_data from What is the preferred method of comparing values? I think it's too generic to not exist in std... // Maybe I can make `return false` on `...
agatzan's user avatar
  • 31
0 votes
1 answer
68 views

Consider the following OpenCL code in which each element in a vector-type variable gets its value via array lookup: float* tbl = get_data(); int4 offsets = get_offsets(); float4 my_elements = { ...
einpoklum's user avatar
  • 140k
0 votes
0 answers
61 views

I have a project which depends on a certain library libfoo which doesn't have a CMake find module, nor does it have a CMake config file one can use. So, I'm thinking of writing a FindFoo.cmake module. ...
einpoklum's user avatar
  • 140k
35 votes
2 answers
4k views

I am starting to learn Rust. In a lot of examples I have come across so far, I have noticed that functions are often implemented to return variables by value even if they are of a complex data type ...
fritut08's user avatar
  • 497
1 vote
2 answers
153 views

In some languages, we can declare and initialize an anonymous struct - or the equivalent thereof - seamlessly. Example from ECMAScript: function foo_in_ecmascript(x) { let computed = { ...
einpoklum's user avatar
  • 140k
0 votes
1 answer
38 views

OpenCL C supports "vector data types" - a fixed number of scalar types which may be operated on together, as though they were a single scalar, mostly: we can apply arithmetic and logic ...
einpoklum's user avatar
  • 140k
2 votes
1 answer
157 views

The C++ standard library, and specifically its part involving containers and ranges, is mostly "one-dimensionally oriented" - things have a start and and end you go from start to end. If you ...
einpoklum's user avatar
  • 140k
5 votes
0 answers
267 views

In this earlier SO question: What is a smart pointer and when should I use one? Ten years ago, I gave a relative simple answer and got a bunch of upvotes. One paragraph in my answer reads: Use std::...
einpoklum's user avatar
  • 140k
0 votes
2 answers
120 views

I thought the let and elvis operator would take care of nullable another way it seems to. In my above example, I want to check for a for being not null and returnSomethingNullable or in case a is null ...
Pipo's user avatar
  • 5,211
-5 votes
1 answer
90 views

I'm working on some JS code (which will run within Thunderbird, but that's not the main point). This code is kind of old, and does asynchronous work using setTimeout(); I want to transition it to ...
einpoklum's user avatar
  • 140k
3 votes
2 answers
170 views

I want the user to be able to pass the struct along and instantiate it without a constructor function, but not be able to modify the structure's fields without using the setter methods provided in the ...
GrimOutlook's user avatar

15 30 50 per page
1
2 3 4 5
84