Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <array>
- #include "A.h"
- #include "printer.hpp"
- template <typename Collection>
- auto incrementIfPossible(Collection&& collection) {
- for (auto&& item : collection) {
- using Item = decltype(item);
- constexpr bool isMutable = !std::is_const_v<std::remove_reference_t<Item>>;
- if constexpr (isMutable) {
- ++item;
- }
- }
- }
- auto main() -> int {
- printLn("=== main begin ==========================");
- using Arr = std::array<A, 3>;
- incrementIfPossible(Arr {{ {3}, {5}, {7} }});
- const Arr carr {{ {9}, {11}, {13} }};
- incrementIfPossible(carr);
- printLn("=== main end ============================");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement