More constexpr and noexcept support.

Note 1: Forwarding functions are specified as a C++14 constexpr since
std::forward is not a constexpr within C++11.

Note 2: Though I'm not sure why it doesn't compile, some declarations
are specified as a C++14 constexpr or non-constexpr.

Note 3: Boost.Tuple adaptation and TR1-based tuple implementations are
not constexpr.
This commit is contained in:
Kohei Takahashi
2015-03-03 02:21:02 +09:00
parent d7c918e36f
commit 2114bfca6c
280 changed files with 1107 additions and 935 deletions

View File

@ -7,6 +7,9 @@
#ifndef BOOST_FUSION_SUPPORT_AS_CONST_HPP
#define BOOST_FUSION_SUPPORT_AS_CONST_HPP
#include <boost/config.hpp>
#include <boost/fusion/support/config.hpp>
namespace boost { namespace fusion { namespace extension
{
// A customization point that allows certain wrappers around
@ -16,8 +19,8 @@ namespace boost { namespace fusion { namespace extension
// such contexts with calls to this function. Users can
// specialize this function for their own wrappers.
template <typename T>
BOOST_FUSION_GPU_ENABLED
const T& as_const(const T& obj)
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
inline const T& as_const(const T& obj) BOOST_NOEXCEPT
{
return obj;
}

View File

@ -66,8 +66,8 @@ namespace boost { namespace fusion
}
template <typename Cur, typename Context>
BOOST_FUSION_GPU_ENABLED
typename result_of::make_segmented_iterator<Cur, Context>::type
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
inline typename result_of::make_segmented_iterator<Cur, Context>::type
make_segmented_iterator(Cur const& cur, Context const& context)
{
typedef result_of::make_segmented_iterator<Cur, Context> impl_type;
@ -121,7 +121,7 @@ namespace boost { namespace fusion
typedef iterator_range<Cur, End> range_type;
typedef cons<range_type, Context> type;
BOOST_FUSION_GPU_ENABLED
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static type call(Cur const& cur, End const& end, Context const& context)
{
return cons<range_type, Context>(range_type(cur, end), context);
@ -170,7 +170,7 @@ namespace boost { namespace fusion
typedef typename impl::type type;
typedef typename impl::continue_type continue_type;
BOOST_FUSION_GPU_ENABLED
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static type call(Sequence& seq, State const& state, Context const& context, Fun const& fun)
{
return impl::call(fusion::segments(seq), state, context, fun);
@ -192,7 +192,7 @@ namespace boost { namespace fusion
typedef typename apply_type::type type;
typedef typename apply_type::continue_type continue_type;
BOOST_FUSION_GPU_ENABLED
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static type call(Sequence& seq, State const& state, Context const& context, Fun const& fun)
{
return apply_type::call(seq, state, context, fun);
@ -274,14 +274,14 @@ namespace boost { namespace fusion
>::type
continue_type;
BOOST_FUSION_GPU_ENABLED
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static type call(Begin const& beg, End const& end, State const& state
, Context const& context, Fun const& fun)
{
return call(beg, end, state, context, fun, typename fold_recurse_impl::continue_type());
}
BOOST_FUSION_GPU_ENABLED
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static type call(Begin const& beg, End const& end, State const& state
, Context const& context, Fun const& fun, mpl::true_) // continue
{
@ -297,7 +297,7 @@ namespace boost { namespace fusion
, fun);
}
BOOST_FUSION_GPU_ENABLED
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static type call(Begin const& beg, End const& end, State const& state
, Context const& context, Fun const& fun, mpl::false_) // break
{
@ -325,7 +325,7 @@ namespace boost { namespace fusion
typedef typename impl::type type;
typedef typename impl::continue_type continue_type;
BOOST_FUSION_GPU_ENABLED
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static type call(Begin const& beg, End const& end, State const& state
, Context const& context, Fun const& fun)
{
@ -351,7 +351,7 @@ namespace boost { namespace fusion
typedef typename impl::type type;
typedef typename impl::continue_type continue_type;
BOOST_FUSION_GPU_ENABLED
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static type call(Begin const& beg, End const& end, State const& state
, Context const& context, Fun const& fun)
{
@ -365,7 +365,7 @@ namespace boost { namespace fusion
typedef State type;
typedef mpl::true_ continue_type;
BOOST_FUSION_GPU_ENABLED
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static type call(Begin const&, End const&, State const& state
, Context const&, Fun const&)
{
@ -389,7 +389,7 @@ namespace boost { namespace fusion
typedef typename impl::type type;
typedef typename impl::continue_type continue_type;
BOOST_FUSION_GPU_ENABLED
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static type call(Segments& segs, State const& state, Context const& context, Fun const& fun)
{
return impl::call(fusion::begin(segs), fusion::end(segs), state, context, fun);

View File

@ -7,6 +7,7 @@
#if !defined(FUSION_ITERATOR_BASE_05042005_1008)
#define FUSION_ITERATOR_BASE_05042005_1008
#include <boost/config.hpp>
#include <boost/fusion/support/config.hpp>
namespace boost { namespace fusion
@ -16,16 +17,16 @@ namespace boost { namespace fusion
template <typename Iterator>
struct iterator_base : iterator_root
{
BOOST_FUSION_GPU_ENABLED
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
Iterator const&
cast() const
cast() const BOOST_NOEXCEPT
{
return static_cast<Iterator const&>(*this);
}
BOOST_FUSION_GPU_ENABLED
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
Iterator&
cast()
cast() BOOST_NOEXCEPT
{
return static_cast<Iterator&>(*this);
}

View File

@ -29,51 +29,47 @@ namespace boost { namespace fusion
template <typename First, typename Second>
struct pair
{
BOOST_FUSION_GPU_ENABLED
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
pair()
: second() {}
BOOST_FUSION_GPU_ENABLED
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
pair(pair const& rhs)
: second(rhs.second) {}
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
BOOST_FUSION_GPU_ENABLED
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
pair(pair&& rhs)
: second(BOOST_FUSION_FWD_ELEM(Second, rhs.second)) {}
#endif
BOOST_FUSION_GPU_ENABLED
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
pair(typename detail::call_param<Second>::type val)
: second(val) {}
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
BOOST_FUSION_GPU_ENABLED
template <typename Second2>
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
pair(Second2&& val
, typename boost::disable_if<is_lvalue_reference<Second2> >::type* /* dummy */ = 0
, typename boost::enable_if<is_convertible<Second2, Second> >::type* /*dummy*/ = 0
) : second(BOOST_FUSION_FWD_ELEM(Second, val)) {}
#endif
template <typename Second2>
BOOST_FUSION_GPU_ENABLED
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
pair(pair<First, Second2> const& rhs)
: second(rhs.second) {}
template <typename Second2>
BOOST_FUSION_GPU_ENABLED
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
pair& operator=(pair<First, Second2> const& rhs)
{
second = rhs.second;
return *this;
}
BOOST_FUSION_GPU_ENABLED
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
pair& operator=(pair const& rhs)
{
second = rhs.second;
@ -81,7 +77,7 @@ namespace boost { namespace fusion
}
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
BOOST_FUSION_GPU_ENABLED
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
pair& operator=(pair&& rhs)
{
second = BOOST_FUSION_FWD_ELEM(Second, rhs.second);
@ -117,7 +113,7 @@ namespace boost { namespace fusion
}
template <typename First, typename Second>
BOOST_FUSION_GPU_ENABLED
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
inline typename result_of::make_pair<First,Second>::type
make_pair(Second const& val)
{
@ -141,7 +137,7 @@ namespace boost { namespace fusion
}
template <typename First, typename SecondL, typename SecondR>
BOOST_FUSION_GPU_ENABLED
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
inline bool
operator==(pair<First, SecondL> const& l, pair<First, SecondR> const& r)
{
@ -149,7 +145,7 @@ namespace boost { namespace fusion
}
template <typename First, typename SecondL, typename SecondR>
BOOST_FUSION_GPU_ENABLED
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
inline bool
operator!=(pair<First, SecondL> const& l, pair<First, SecondR> const& r)
{
@ -157,7 +153,7 @@ namespace boost { namespace fusion
}
template <typename First, typename SecondL, typename SecondR>
BOOST_FUSION_GPU_ENABLED
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
inline bool
operator<(pair<First, SecondL> const& l, pair<First, SecondR> const& r)
{

View File

@ -45,7 +45,7 @@ namespace boost { namespace fusion
}
template <typename Sequence, typename State, typename Fun>
BOOST_FUSION_GPU_ENABLED
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
inline typename
lazy_disable_if<
is_const<Sequence>
@ -56,19 +56,19 @@ namespace boost { namespace fusion
typedef
typename result_of::segmented_fold_until<Sequence, State, Fun>::filter
filter;
return filter::call(seq, state, fusion::nil_(), fun);
}
template <typename Sequence, typename State, typename Fun>
BOOST_FUSION_GPU_ENABLED
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
inline typename result_of::segmented_fold_until<Sequence const, State, Fun>::type
segmented_fold_until(Sequence const& seq, State const& state, Fun const& fun)
{
typedef
typename result_of::segmented_fold_until<Sequence const, State, Fun>::filter
filter;
return filter::call(seq, state, fusion::nil_(), fun);
}
}}

View File

@ -8,6 +8,7 @@
#if !defined(FUSION_SEQUENCE_BASE_04182005_0737)
#define FUSION_SEQUENCE_BASE_04182005_0737
#include <boost/config.hpp>
#include <boost/fusion/support/config.hpp>
#include <boost/mpl/begin_end_fwd.hpp>
@ -22,22 +23,22 @@ namespace boost { namespace fusion
template <typename Sequence>
struct sequence_base
{
BOOST_FUSION_GPU_ENABLED
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
Sequence const&
derived() const
derived() const BOOST_NOEXCEPT
{
return static_cast<Sequence const&>(*this);
}
BOOST_FUSION_GPU_ENABLED
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
Sequence&
derived()
derived() BOOST_NOEXCEPT
{
return static_cast<Sequence&>(*this);
}
BOOST_FUSION_GPU_ENABLED
operator detail::from_sequence_convertible_type()const
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
operator detail::from_sequence_convertible_type() const BOOST_NOEXCEPT
{
return detail::from_sequence_convertible_type();
}

View File

@ -22,65 +22,67 @@ namespace boost { namespace fusion
{
struct unused_type
{
BOOST_FUSION_GPU_ENABLED
unused_type()
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
unused_type() BOOST_NOEXCEPT
{
}
template <typename T>
BOOST_FUSION_GPU_ENABLED
unused_type(T const&)
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
unused_type(T const&) BOOST_NOEXCEPT
{
}
template <typename T>
BOOST_FUSION_GPU_ENABLED
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
unused_type const&
operator=(T const&) const
operator=(T const&) const BOOST_NOEXCEPT
{
return *this;
}
template <typename T>
BOOST_FUSION_GPU_ENABLED
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
unused_type&
operator=(T const&)
operator=(T const&) BOOST_NOEXCEPT
{
return *this;
}
BOOST_FUSION_GPU_ENABLED
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
unused_type const&
operator=(unused_type const&) const
operator=(unused_type const&) const BOOST_NOEXCEPT
{
return *this;
}
BOOST_FUSION_GPU_ENABLED
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
unused_type&
operator=(unused_type const&)
operator=(unused_type const&) BOOST_NOEXCEPT
{
return *this;
}
};
unused_type const unused = unused_type();
BOOST_CONSTEXPR unused_type const unused = unused_type();
namespace detail
{
struct unused_only
{
BOOST_FUSION_GPU_ENABLED
unused_only(unused_type const&) {}
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
unused_only(unused_type const&) BOOST_NOEXCEPT {}
};
}
inline std::ostream& operator<<(std::ostream& out, detail::unused_only const&)
BOOST_CONSTEXPR
inline std::ostream& operator<<(std::ostream& out, detail::unused_only const&) BOOST_NOEXCEPT
{
return out;
}
inline std::istream& operator>>(std::istream& in, unused_type&)
BOOST_CONSTEXPR
inline std::istream& operator>>(std::istream& in, unused_type&) BOOST_NOEXCEPT
{
return in;
}