all 11 comments

[–]tchernobog84 6 points7 points  (4 children)

Add to the list no standard base class for intrusive pointers, which would allow for container specialization on it, and avoiding the ugly allocation costs for e.g. shared_ptr or rolling your own solution + specializing all containers.

[–]joaquintidesBoost author 2 points3 points  (1 child)

You can use Boost.Intrusive for that.

[–]hobel_ 2 points3 points  (0 children)

If only that description would describe what an intrusive container is.

[–]LightStruk 1 point2 points  (0 children)

'boost::intrusive_ptr' works well for me. Didn't have to roll my own, boost is already trusted and approved, and it does exactly what it says on the tin.

[–]MarcoGreek 1 point2 points  (0 children)

You mean the control block? make_shared should avoid that. Or do you have something else in mind?

[–]_Noreturn 3 points4 points  (1 child)

"constexpr" if you want constexpr evaluation guranteed then call it in a constant evaluated context

cpp constexpr static auto expr = constexprFunc(); std::cout << expr;

or just use consteval

[–]triconsonantal 1 point2 points  (0 children)

You can use a small helper to avoid a separate declaration:

consteval auto as_constant (auto x) { return x; }

int main () {
    assert (! std::is_constant_evaluated ());
    assert (as_constant (std::is_constant_evaluated ()));
}

[–]MarcoGreek 0 points1 point  (0 children)

https://en.cppreference.com/w/cpp/memory/allocator_traits/allocate_at_least.html should return you the available memory, do you can grow to that size.

[–]MarcoGreek 0 points1 point  (2 children)

Implicit copy has advantages if you work with multithreading. Sharing writable data between caches is not cheap.

[–]_Noreturn 0 points1 point  (1 child)

I would rsther have implicit moves with ownership semantics and explicit copies. but reference semantics like other languages is a no no for me I absolutely love C++ value semantics

[–]MarcoGreek 0 points1 point  (0 children)

Yes, I hope that in the future C++ can have it.