Boost logo

Boost :

From: Ivan Matek (libbooze_at_[hidden])
Date: 2024-12-06 18:16:40


On Fri, Dec 6, 2024 at 7:06 PM Vinnie Falco via Boost <boost_at_[hidden]>
wrote:

> This is quite informative, thank you. For my entire career I have avoided
> passing C-style arrays because of ignorance of how they work. Is it a copy?
> Is it just a pointer? Does the compiler know the extent? And so on. I don't
> like the look of function signatures which accept language arrays, because
> they do not quite work the same way as other types.
>
> I had the same "issue" until I remembered a simple C++ program that shows
how compiler sees this functions.

void f(int arr[3]) {

}

void f(int arr[4]) {
}

compiler will complain:

 <source>:5:6: error: redefinition of 'void f(int*)' 5 | void f(int arr[4])
{ |
 <source>:1:6: note: 'void f(int*)' previously defined here 1 | void f(int
arr[3]) {

So I also in general prefer fixed extent span, but we must remember that
that can lead to code size bloat, and that is usually undetectable in micro
benchmarks, but can slow down large programs.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk