diff options
Diffstat (limited to 'src/boost/libs/hana/test/ext/std/array/at.cpp')
-rw-r--r-- | src/boost/libs/hana/test/ext/std/array/at.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/boost/libs/hana/test/ext/std/array/at.cpp b/src/boost/libs/hana/test/ext/std/array/at.cpp new file mode 100644 index 000000000..90ed1f5b7 --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/array/at.cpp @@ -0,0 +1,43 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include <boost/hana/ext/std/array.hpp> + +#include <boost/hana/assert.hpp> +#include <boost/hana/at.hpp> + +#include <laws/base.hpp> // for move_only + +#include <array> +namespace hana = boost::hana; + + +int main() { + // Check non-const lvalue reference + { + std::array<int, 2> arr = {{999, 888}}; + int& i = hana::at_c<0>(arr); + BOOST_HANA_RUNTIME_CHECK(i == 999); + arr[0] = 333; + BOOST_HANA_RUNTIME_CHECK(i == 333); + i = 444; + BOOST_HANA_RUNTIME_CHECK(arr[0] == 444); + } + + // Check const lvalue reference + { + std::array<int, 2> arr = {{999, 888}}; + int const& i = hana::at_c<0>(static_cast<std::array<int, 2> const&>(arr)); + BOOST_HANA_RUNTIME_CHECK(i == 999); + arr[0] = 333; + BOOST_HANA_RUNTIME_CHECK(i == 333); + } + + // Check move-only types + { + std::array<hana::test::move_only, 2> arr{}; + hana::test::move_only m = hana::at_c<0>(std::move(arr)); + (void)m; + } +} |