/*============================================================================= Copyright (c) 2011-2013 Bolero MURAKAMI https://github.com/bolero-MURAKAMI/Sprout Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ #ifndef SPROUT_WEED_ATTR_CNV_BITWISE_OR_HPP #define SPROUT_WEED_ATTR_CNV_BITWISE_OR_HPP #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace sprout { namespace weed { namespace attr_cnv { // // bitwise_or // // container | container -> container template inline SPROUT_CONSTEXPR typename std::enable_if< sprout::weed::detail::is_same_container::value, typename sprout::weed::attr_cnv::result_of::bitwise_or::type >::type bitwise_or(X const& x) { typedef typename sprout::weed::attr_cnv::result_of::bitwise_or::type type; return sprout::fixed::realign_to(x); } // container | V -> container template inline SPROUT_CONSTEXPR typename std::enable_if< sprout::weed::detail::is_container_and_elem::value && sprout::weed::traits::is_container::value, typename sprout::weed::attr_cnv::result_of::bitwise_or::type >::type bitwise_or(X const& x) { typedef typename sprout::weed::attr_cnv::result_of::bitwise_or::type type; return sprout::fixed::realign_to(x); } template inline SPROUT_CONSTEXPR typename std::enable_if< sprout::weed::detail::is_container_and_elem::value && !sprout::weed::traits::is_container::value, typename sprout::weed::attr_cnv::result_of::bitwise_or::type >::type bitwise_or(X const& x) { typedef typename sprout::weed::attr_cnv::result_of::bitwise_or::type type; return sprout::make(x); } // V | container -> container template inline SPROUT_CONSTEXPR typename std::enable_if< sprout::weed::detail::is_elem_and_container::value && sprout::weed::traits::is_container::value, typename sprout::weed::attr_cnv::result_of::bitwise_or::type >::type bitwise_or(X const& x) { typedef typename sprout::weed::attr_cnv::result_of::bitwise_or::type type; return sprout::fixed::realign_to(x); } template inline SPROUT_CONSTEXPR typename std::enable_if< sprout::weed::detail::is_elem_and_container::value && !sprout::weed::traits::is_container::value, typename sprout::weed::attr_cnv::result_of::bitwise_or::type >::type bitwise_or(X const& x) { typedef typename sprout::weed::attr_cnv::result_of::bitwise_or::type type; return sprout::make(x); } // tuple | tuple -> tuple template inline SPROUT_CONSTEXPR typename std::enable_if< sprout::weed::detail::is_both_tuple::value, typename sprout::weed::attr_cnv::result_of::bitwise_or::type >::type bitwise_or(X const& x) { typedef typename sprout::weed::attr_cnv::result_of::bitwise_or::type type; return sprout::tuples::copy(type(), x); } // V | V -> V template inline SPROUT_CONSTEXPR typename std::enable_if< sprout::weed::detail::is_same_elem::value, typename sprout::weed::attr_cnv::result_of::bitwise_or::type >::type bitwise_or(X const& x) { return x; } // V | W -> variant template inline SPROUT_CONSTEXPR typename std::enable_if< sprout::weed::detail::is_different_elem::value, typename sprout::weed::attr_cnv::result_of::bitwise_or::type >::type bitwise_or(X const& x) { return typename sprout::weed::attr_cnv::result_of::bitwise_or::type(x); } // V | unused -> container template inline SPROUT_CONSTEXPR typename std::enable_if< sprout::weed::detail::is_elem_and_unused::value && !sprout::weed::traits::is_unused::value, typename sprout::weed::attr_cnv::result_of::bitwise_or::type >::type bitwise_or(X const& x) { typedef typename sprout::weed::attr_cnv::result_of::bitwise_or::type type; return sprout::make(x); } template inline SPROUT_CONSTEXPR typename std::enable_if< sprout::weed::detail::is_elem_and_unused::value && sprout::weed::traits::is_unused::value, typename sprout::weed::attr_cnv::result_of::bitwise_or::type >::type bitwise_or(X const&) { typedef typename sprout::weed::attr_cnv::result_of::bitwise_or::type type; return sprout::make(); } // unused | V -> container template inline SPROUT_CONSTEXPR typename std::enable_if< sprout::weed::detail::is_unused_and_elem::value && !sprout::weed::traits::is_unused::value, typename sprout::weed::attr_cnv::result_of::bitwise_or::type >::type bitwise_or(X const& x) { typedef typename sprout::weed::attr_cnv::result_of::bitwise_or::type type; return sprout::make(x); } template inline SPROUT_CONSTEXPR typename std::enable_if< sprout::weed::detail::is_unused_and_elem::value && sprout::weed::traits::is_unused::value, typename sprout::weed::attr_cnv::result_of::bitwise_or::type >::type bitwise_or(X const&) { typedef typename sprout::weed::attr_cnv::result_of::bitwise_or::type type; return sprout::make(); } // unused | unused -> unused template inline SPROUT_CONSTEXPR typename std::enable_if< sprout::weed::detail::is_both_unused::value, typename sprout::weed::attr_cnv::result_of::bitwise_or::type >::type bitwise_or(X const&) { return sprout::weed::unused(); } } // namespace attr_cnv } // namespace weed } // namespace sprout #endif // #ifndef SPROUT_WEED_ATTR_CNV_BITWISE_OR_HPP