|
Server : Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 DAV/2 PHP/5.2.17 System : Linux localhost 2.6.18-419.el5 #1 SMP Fri Feb 24 22:47:42 UTC 2017 x86_64 User : nobody ( 99) PHP Version : 5.2.17 Disable Function : NONE Directory : /usr/include/boost/spirit/core/impl/ |
Upload File : |
/*=============================================================================
Copyright (c) 1998-2003 Joel de Guzman
http://spirit.sourceforge.net/
Use, modification and distribution is subject to 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)
=============================================================================*/
#if !defined(BOOST_SPIRIT_MATCH_ATTR_TRAITS_IPP)
#define BOOST_SPIRIT_MATCH_ATTR_TRAITS_IPP
#include <boost/optional.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/mpl/or.hpp>
#include <boost/type_traits/is_convertible.hpp>
#include <boost/type_traits/is_same.hpp>
namespace boost { namespace spirit { namespace impl
{
template <typename T>
struct match_attr_traits
{
typedef typename
boost::optional<T>::reference_const_type
const_reference;
// case where src *IS* convertible to T (dest)
template <typename T2>
static void
convert(boost::optional<T>& dest, T2 const& src, mpl::true_)
{
dest.reset(src);
}
// case where src *IS NOT* convertible to T (dest)
template <typename T2>
static void
convert(boost::optional<T>& dest, T2 const& /*src*/, mpl::false_)
{
dest.reset();
}
static void
convert(boost::optional<T>& dest, nil_t/*src*/)
{
dest.reset();
}
template <typename T2>
static void
convert(boost::optional<T>& dest, T2 const& src)
{
convert(dest, src, is_convertible<T2, T>());
}
template <typename OtherMatchT>
static void
copy(boost::optional<T>& dest, OtherMatchT const& src)
{
if (src.has_valid_attribute())
convert(dest, src.value());
}
template <typename OtherMatchT>
static void
assign(boost::optional<T>& dest, OtherMatchT const& src)
{
if (src.has_valid_attribute())
convert(dest, src.value());
else
dest.reset();
}
// T is not reference
template <typename ValueT>
static void
set_value(boost::optional<T>& dest, ValueT const& val, mpl::false_)
{
dest.reset(val);
}
// T is a reference
template <typename ValueT>
static void
set_value(boost::optional<T>& dest, ValueT const& val, mpl::true_)
{
dest.get() = val;
}
};
}}} // namespace boost::spirit::impl
#endif