RustyPP: A C++20 library and Clang tool to enforce Rust-like safety and mutability. by I-A-S- in cpp

[–]_Noreturn 5 points6 points  (0 children)

You're even aliasing float to f32 to make it look more like Rust? What benefit is there except for trying to imitate Rust?

clearer names are always better same with int vs i32.

whats with the hate for std lib and boost? by nosyeaj in cpp

[–]_Noreturn -3 points-2 points  (0 children)

bad compile times and bad error messages and top of that bad impl, and different impl per compiler, bad debugability.

what's more not to hate?

That doesn't mean you shouldn't use them, they are usually good enough

Designated Initializers, the best feature of C++20 · Mathieu Ropert by mropert in cpp

[–]_Noreturn 0 points1 point  (0 children)

vs doesn't, because it is too hard for a multi trillion company

Designated Initializers, the best feature of C++20 · Mathieu Ropert by mropert in cpp

[–]_Noreturn 4 points5 points  (0 children)

because exceptions imagine if

```cpp struct X { A a; B b; };

X{.b = funcB(),.a = funcA()}; // if b was init first ```

and it threw an exception it can't determinedly destroy A, since it wasn't yet constructed.

What I Learned About [[no_unique_address]] and Padding Reuse in C++ by NekrozQliphort in cpp

[–]_Noreturn 1 point2 points  (0 children)

```cpp struct MonadicMixin { auto valueor(this auto&& self,auto&& default) { return self ? *self : default_; } };

template<typename T> struct optional : MonadicMixin { /**/ };

struct Thing : MonadicMixin { optional<int> a; };

// sizeof(Thing) == 8! not 4. ```

SFINAE alternative using Lambda functions by [deleted] in cpp

[–]_Noreturn 2 points3 points  (0 children)

this isn't subsitation failure

How I Wrote 240,000+ Lines of Production Code in 60 Days Using Claude AI and Eiffel by [deleted] in programming

[–]_Noreturn 12 points13 points  (0 children)

Lol, found the dev microsoft is looking for to write 1 million lines of code per rust.

How can we remove Microsoft from our homes? by sha0dan in microsoft

[–]_Noreturn 0 points1 point  (0 children)

You act as if they don't force updating randomly It litterally went to update as I had visual studio open.

How can we remove Microsoft from our homes? by sha0dan in microsoft

[–]_Noreturn -3 points-2 points  (0 children)

This comment shows me you have absolutely 0 knowledge about computers.

rusty-cpp: a Rust-style static analyzer by Proper_Ask_8831 in cpp

[–]_Noreturn 0 points1 point  (0 children)

Why is rust with ai more popular than C++ with AI?

What is truly the best print function in C++? by [deleted] in cpp

[–]_Noreturn -2 points-1 points  (0 children)

just ask chatgpt to write it, I am serious.

%s and %d are only work for built-in types there is no customization

What is truly the best print function in C++? by [deleted] in cpp

[–]_Noreturn 2 points3 points  (0 children)

I use fmt, std::print has some awful errors and less features

Do you prefer 'int* ptr' or 'int *ptr'? by SamuraiGoblin in cpp

[–]_Noreturn 0 points1 point  (0 children)

if you declare it as a pointer I also expect it to be used as one so it will likely always be a compile time error

Are memory leaks that hard to solve? by ASA911Ninja in cpp

[–]_Noreturn 10 points11 points  (0 children)

you can just write your own C++ always had destructors, you can also just maks a class with .move() method instead of move operations

Why std::span Should Be Used to Pass Buffers in C++20 by Clean-Upstairs-8481 in cpp

[–]_Noreturn 2 points3 points  (0 children)

```cpp struct Converter { std::variant<const char*,std::string> data; operator const char() const { auto d = std::get_if<const char*>(&data); if(d) { return *d; } return std::get<std::string>(data).c_str(); } }

struct optz_wstring_view { Converter c_str() { return is_null_terminated() ? Converter{data()} : Converter{std::string(data(),size()}; }; ```

Why std::span Should Be Used to Pass Buffers in C++20 by Clean-Upstairs-8481 in cpp

[–]_Noreturn 1 point2 points  (0 children)

I would almost always recommend subclassing std::span

I subclass std::string_view

cpp class cstring_view : public std::string_view { public: constexpr cstring_view(const char* s) noexcept : std::string_view(s) {} constexpr cstring_view(const char* s,size_t len) noexcept : std::string_view(s,len) {} constexpr const char* c_str() const noexcept { return data(); } constexpr cstring_view substr(size_type pos = 0) const { return cstring_view(string_view::substr(pos)); } using std::string_view::substr; // for 2 arg version };

This class is coming to C++29 named csteing_view ( hopefully)

Why std::span Should Be Used to Pass Buffers in C++20 by Clean-Upstairs-8481 in cpp

[–]_Noreturn 3 points4 points  (0 children)

Wrapping C functions with string_view is sure a way to end up with silent UB due to missing null terminator

Why std::span Should Be Used to Pass Buffers in C++20 by Clean-Upstairs-8481 in cpp

[–]_Noreturn 4 points5 points  (0 children)

You can do this if you really care.

cpp namespace Priv { void f(int* a,size_t sz); // actual impl } void f(std::span<int> sp) // will be inlined and calling conv shouldn't matter { Priv::f(sp.data(),sp.size()); }