Skip to content
Snippets Groups Projects
Commit dec25615 authored by Martin Nolte's avatar Martin Nolte
Browse files

Merge branch 'fix/c++11-compatible-filledarray' into 'releases/2.6'

Remove constexpr from filledArray().

See merge request !412
parents caffb8d1 6a8d6305
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.
Please register or to comment