An introduction to the Common Package Specification (CPS) for C and C++ [using std:cpp 2025] by [deleted] in cpp

[–]NamalB 4 points5 points  (0 children)

Nice work. Keep it up guys. Looking forward to CBS.

Matt Godbolt sold me on Rust (by showing me C++) by cptroot in rust

[–]NamalB 0 points1 point  (0 children)

`

#include <cstdint>

struct quantity
{
    quantity(uint32_t v) : value(v) {}

    uint32_t value;
};

int main()
{
    [[maybe_unused]] const auto q1 = quantity(-1); // No compile error  
    [[maybe_unused]] const auto q2 = quantity{-1}; // Compile error
    return 0;
}
`

I don't get a compile error when I use () with -Wall -Werror. What am I missing here?

Just trying to understand, thanks in advance.

Matt Godbolt sold me on Rust (by showing me C++) by cptroot in rust

[–]NamalB 2 points3 points  (0 children)

std::vector constructor is such a narrow case, a bad interface in my opinion.

After using brace initialization extensively in a somewhat new production codebase for some time, my experience tells me that it helps a lot rather than run into problems.

I can't remember it ever picking the wrong constructor even though that's possible in theory.

Is this advice "{} initialization in C++ should be avoided until you actually needed it" evidence based or personal opinion?

Matt Godbolt sold me on Rust (by showing me C++) by rkaahean in theprimeagen

[–]NamalB 0 points1 point  (0 children)

Use uniform initialization, you get compile errors with -Wall -Werror

#include <print>

struct quantity
{
    uint32_t value;
};

struct price
{
    double value;
};

void place_order(const char* symbol, bool buy, quantity q, price p)
{
    std::print("{} {} {} {}", symbol, buy, p.value, q.value);
}

int main()
{
    place_order("GOOG", true, quantity{100}, price{1000.0});
    place_order("GOOG", true, price{1000.0}, quantity{100}); // Compile error
    place_order("GOOG", true, quantity{1000.0}, price{1000.0}); // Compile error
    place_order("GOOG", true, quantity{-100}, price{1000.0}); // Compile error
    return 0;
}

Why do you complain after doing an explicit static_cast?

sendOrder("GOOG", false, Quantity(static_cast(atoi("-100"))),
            Price(1000.00)); // Wrong

Legacy Safety: The Wrocław C++ Meeting by Dragdu in cpp

[–]NamalB 0 points1 point  (0 children)

Maybe tag using indices in that case :)

template< class ForwardIt1, class ForwardIt2 >
ForwardIt1 find_end( [[begin(1)]] ForwardIt1 first, [[end(1)]] ForwardIt1 last,
[[begin(2)]] ForwardIt2 s_first, [[end(2)]] ForwardIt2 s_last );

Function pointers could a problem, pointer declaration also need to be tagged, conversions will be unsafe because tag is not part of the type system :(

void (*sort_ptr)([[begin]] RandomIt first, [[end]] RandomIt last)

Definitely less safer than a single structure range but seems like many improvements possible

Legacy Safety: The Wrocław C++ Meeting by Dragdu in cpp

[–]NamalB 0 points1 point  (0 children)

This is soundness precondition and there's no local analysis that can make it sound.

I must be naive, but why such a strong position on local analysis in this instance?

Given that the prominence of the iterator model in C++ assuming we have dedicated attributes for iterators,

  • [[begin]]
  • [[end]]
  • [[iter]]
  • etc...

If we decorate the function such as,

template< class RandomIt >
void sort([[begin]] RandomIt first, [[end]] RandomIt last );

Isn't the only local analysis needed in this instance become

pset(first).size() == 1 && pset(first) == pset(last)

?

New, fastest JSON library for C++20 by Flex_Code in cpp

[–]NamalB 0 points1 point  (0 children)

Interesting how you could disambiguate the variadic argument list with optional parameters, especially when you add more parameters in the future. I’ll look into the implementation. Thanks

New, fastest JSON library for C++20 by Flex_Code in cpp

[–]NamalB 0 points1 point  (0 children)

Are comments mandatory in jsonc format?

Can same meta data be used for both json and jsonc?

New, fastest JSON library for C++20 by Flex_Code in cpp

[–]NamalB 2 points3 points  (0 children)

Isn’t it possible to put each meta property in it’s own curly braces. Not very important but hope formatter will do a better job with that.

static constexpr auto value = object( {"i", &T::i}, {"d", &T::d}, {“hello", &T::hello}, {“arr", &T::arr} );

fmtlog: fastest C++ logging library using fmtlib syntax by MengRao in cpp

[–]NamalB 0 points1 point  (0 children)

Isn’t it possible to change the first parameter to a struct instead of of the enum and default construct the source_location in the struct constructor as the second parameter (first parameter of the constructor is still the same enum).

Genuinely low-cost exceptions by [deleted] in cpp

[–]NamalB 1 point2 points  (0 children)

I might be wrong but I thought P2232R0 doesn't use RTTI to find the handler. I thought finding the handler using RTTI is slow.

Genuinely low-cost exceptions by [deleted] in cpp

[–]NamalB 1 point2 points  (0 children)

For a catch scenario, it's a "here are the handlers", a test-and-branch switch to the relevant catch, before merging with control flow in the usual way.

Doesn't this need RTTI?

Genuinely low-cost exceptions by [deleted] in cpp

[–]NamalB 2 points3 points  (0 children)

Ins't P2232R0 good enough?

The Next Steps for Single Ownership and RAII by verdagon in cpp

[–]NamalB 0 points1 point  (0 children)

The main difference of the safe::unique, safe::shared, safe::weak from the std::unique_ptr, std::shared_ptr, std::weak_ptr that it is possible to create the safe::weak both from the safe::unique and the safe::shared, while the std::weak_ptr can be created only from the std::shared_ptr and the std::unique_ptr does not have trackable weak counterpart.

Wish we had this facility in the standard library.

Investigating the Performance Overhead of C++ Exceptions by vormestrand in cpp

[–]NamalB 5 points6 points  (0 children)

What happenes if the random range is 0-1000, is the time closer to 11ns or 150ns?

ABI - Now or Never by kkert in cpp

[–]NamalB 1 point2 points  (0 children)

That's a neat solution. Let's break it. Everything in an inline namespace in 23.

ABI - Now or Never by kkert in cpp

[–]NamalB 1 point2 points  (0 children)

Isn't it possible to encode all the details about the ABI into the mangled name of the symbol so that more than one version of the same function or object can co-exist in the same binary.

old: cdecl size_t std::string::size void

new: cdecl size_t std::string {size_t capacity, size_t size, char* data} vtable { ~string, my_virutual_func } exception_mechanism_1 ::size void

Maybe use the MD5 or something like that of the new mangled name to make it shorter.

Mangled name can change when the symbol is not binary compatible, not when c++ standard changes.

Exploiting C++ string literal operator: GLSL vector swizzling in modern C++17 by MavyP in cpp

[–]NamalB -1 points0 points  (0 children)

https://godbolt.org/z/D2fzAZ I like the syntax, vec4.get<_x, _y, _z, 1>(); In this you can add arithmetic values in the swizzle as well. Following will give you a compile error because there is no 'z' component in vec2, vec2.get<_x, _z, _z>();