Question: Having an issue (yeah, ok I got issues)... with template methods. In the example below I have a template method DoIt, the actual piece of code works fine. The template method knows the actual size of the buffer being passed (N). But I also want the option of being able to call DoIt passing only a buffer address and a length). That is my method DoItThisWay. 

How do I have DoItThisWay call DoIt in such a way as to limit the size of the buffer recognized by DoIt as only have length siz, as passed to DoItThisWay?

```
template<typename T, size_t N> size_t DoIt(T(&buf)[N], size_t siz) 
{
    // Work done here...
    return 0;
}

size_t DoItThisWay(uint8_t buf[], size_t siz)
{
    return DoIt.........
}

```

Answer: 
In a function argument, `uint8_t buf[]` is just syntax sugar for `uint8_t *buf`.

You cannot pass a raw pointer where a reference to a fixed array is expected. Even if you could, you cannot pass a runtime value like `siz` to a template parameter, only constants that are known at compile-time. So, `DoItThisWay` simply cannot call `DoIt`.

However, a fixed array decays into a pointer to its first element, so `DoIt` can call `DoItThisWay`, but only when `T` is `uint8_t`, thus making `T` redundant (unless you have multiple overloads of `DoItThisWay` for different data types, or give `DoItThisWay` it's own `T` template parameter).

Either way, the `siz` argument of `DoIt` is redundant and should be removed since `DoIt` can use `N` instead.

Try this:

```
size_t DoItThisWay(uint8_t *buf, size_t siz)
{
    // Work done here...
    return 0;
}

template<size_t N>
size_t DoIt(uint8_t(&buf)[N])
{
    return DoItThisWay(buf, N);
}

```

Or

```
size_t DoItThisWay(uint8_t *buf, size_t siz)
{
    // Work done here...
    return 0;
}

// other overloads of DoItThisWay...

template<typename T, size_t N>
size_t DoIt(T(&buf)[N])
{
    return DoItThisWay(buf, N);
}

```

Or

```
template<typename T>
size_t DoItThisWay(T *buf, size_t siz)
{
    // Work done here...
    return 0;
}

template<typename T, size_t N>
size_t DoIt(T(&buf)[N])
{
    return DoItThisWay(buf, N);
}

```
There is no good way to call `DoIt` from `DoItThisWay` since it knows only the type but not the size at compile time. You need both to call `DoIt`.

```
size_t DoItThisWay(uint8_t buf[], size_t siz)
{
    // What value of N can you use here?
    return DoIt.........
}

```

BTW, passing `siz` to `DoIt` is superfluous. You already know the size. It is `N`.