Skip to content
Snippets Groups Projects
Commit 6a8d6305 authored by Jö Fahlke's avatar Jö Fahlke
Browse files

Remove constexpr from filledArray().

Fixes #102, and partly #99.

This makes it compatible with C++11 and thus g++ 4.9.

`filledArray()` effectively wasn't constexpr anyway until C++17, where
`std::array` becomes `constexpr` (for the most part, at least).
parent 8a289c00
No related branches found
No related tags found
3 merge requests!586Centralize CI config for 2.6 release,!531Update CI for 2.6 release branch,!412Remove constexpr from filledArray().
Pipeline #
......@@ -20,18 +20,15 @@ namespace Dune
//! Return an array filled with the provided value.
/**
* \note This function is `constexpr` only in C++17, or, more precisely,
* when `std::array::begin()` and `std::array::end()` are `constexpr`.
*
* \tparam n Size of the returned array.
* \tparam T Value type of the returned array. This is usually deduced
* from `t`.
*/
template<std::size_t n, class T>
constexpr std::array<T, n> filledArray(const T& t)
std::array<T, n> filledArray(const T& t)
{
std::array<T, n> arr{};
// this is constexpr in c++17, `arr.fill(t)` is not
// this would be constexpr in c++17, `arr.fill(t)` is not
for(auto &el : arr)
el = t;
return arr;
......
......@@ -25,15 +25,5 @@ int main() {
status = 1;
}
#ifdef __cpp_lib_array_constexpr
std::cout << "The result of Dune::filledArray() is constexpr" << std::endl;
constexpr auto test2 = Dune::filledArray<2>(2);
(void)test2;
#else // !__cpp_lib_array_constexpr
std::cout << "Not checking whether Dune::filledArray() is constexpr\n"
<< "since the library does not declare std::array as constexpr\n"
<< "(__cpp_lib_array_constexpr is not defined)." << std::endl;
#endif // !__cpp_lib_array_constexpr
return status;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment