jeudi 31 mars 2016

compilation error while using constexpr

#include <stdio.h>
#include <iostream>

using namespace std;

template <typename T, int N>
int ReturnArraySize(T (&arg1)[N]) {
    return N;
}

constexpr int ReturnTheSum(int arg1, int arg2) {
    return arg1 + arg2;
}

int main(int argc, char **argv)
{
    int arr1[20];
    int arr2[ReturnArraySize(arr1)];
    int arr3[ReturnTheSum(ReturnArraySize(arr1), ReturnArraySize(arr2))];

    return 0;
}

When i compile the code i get the following error.

/root/Documents/C++11_Fundamentals/ConstExprRelatedFunc/main.cpp:19:67: error: no matching function for call to 'ReturnArraySize(int [( + 1)])'

Aucun commentaire:

Enregistrer un commentaire