I think the only real wrinkle in something like this is that I'm not sure vectors can be initialized at compile time.
It is definitely possible to achieve something similar. Here's a template meta-programming version.
Code:
C:\Users\jk\Desktop>more sum.cpp
#include <iostream>
#include <cstddef>
static constexpr double arr[3] = {1.2, 3.4, 4.5};
template <typename T, const T *arr, const size_t idx> struct sum
{
static constexpr T value = arr[idx-1] + sum<T,arr,idx-1>::value;
};
template<typename T, const T *arr> struct sum<T, arr, 1>
{
static constexpr T value = arr[0];
};
int main()
{
std::cout << sum<double, arr, 3>::value << std::endl;
}
C:\Users\jk\Desktop>g++ -std=c++11 -c sum.cpp
C:\Users\jk\Desktop>g++ sum.o -o sum
C:\Users\jk\Desktop>sum
9.1