Skip to content

Commit

Permalink
Drop C++03 support (#107)
Browse files Browse the repository at this point in the history
Drop boost::move and boost::bind dependencies. Use Boost.PP in less cases
  • Loading branch information
apolukhin authored Aug 25, 2023
1 parent d48711f commit 7b45064
Show file tree
Hide file tree
Showing 33 changed files with 89 additions and 1,000 deletions.
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@ target_include_directories( boost_variant INTERFACE include )
target_link_libraries( boost_variant
INTERFACE
Boost::assert
Boost::bind
Boost::config
Boost::container_hash
Boost::core
Boost::detail
Boost::integer
Boost::move
Boost::mpl
Boost::preprocessor
Boost::static_assert
Expand Down
5 changes: 1 addition & 4 deletions doc/reference/apply_visitor.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@
<code><functionname>apply_visitor</functionname></code> on the
stored visitor using the given operands.</simpara>
</description>
<notes>Version with variadic templates is used by default if
<macroname>BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES</macroname> is not defined.</notes>
</overloaded-method>
</method-group>
</class>
Expand All @@ -111,8 +109,7 @@
<simpara>See <code><classname>apply_visitor_delayed_t</classname></code>
which is used when <code>Visitor</code> has <code>result_type</code>
typedef.</simpara>
<simpara>Available only if macro
<macroname>BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES</macroname> is not defined and
<simpara>Available only if
compiler supports <code>decltype(auto)</code> and <code>decltype(some-expression)</code>.</simpara>
</description>

Expand Down
16 changes: 0 additions & 16 deletions doc/reference/multivisitor.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,6 @@
<para>Provides declarations of <functionname>apply_visitor</functionname> for three or more
<code><classname>variant</classname></code> parameters.</para>

<macro name="BOOST_VARAINT_MAX_MULTIVIZITOR_PARAMS">
<purpose>
<simpara>Controls maximum amount of <code><classname>variant</classname></code>
parameters for multi visistors. Not used when <code>std::tuple</code> is available and
<code><macroname>BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES</macroname></code>
is not defined.</simpara>
</purpose>

<description>
<para><emphasis role="bold">Note</emphasis>: Default amount is 4. Define it
to bigger value before including &lt;boost/variant/multivisitors.hpp&gt; to
increase maximum amount of <code><classname>variant</classname></code>
parameters for <functionname>apply_visitor</functionname>.</para>
</description>
</macro>

<namespace name="boost">
<overloaded-function name="apply_visitor /*three or more variant parameters*/">
<description>
Expand Down
38 changes: 2 additions & 36 deletions doc/reference/variant_fwd.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,36 +19,6 @@
class templates and the <code>boost::recursive_variant_</code> tag type.
Also defines several preprocessor symbols, as described below.</para>

<macro name="BOOST_VARIANT_LIMIT_TYPES">
<purpose>
<simpara>Expands to the length of the
template parameter list for
<code><classname>variant</classname></code>. Not used if
<code><macroname>BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES</macroname></code>
is not defined.
</simpara>
</purpose>

<description>
<para><emphasis role="bold">Note</emphasis>: Conforming
implementations of <code>variant</code> must allow at least ten
template arguments. That is, BOOST_VARIANT_LIMIT_TYPES must be greater
or equal to <code>10</code>.</para>
</description>
</macro>

<macro name="BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES">
<purpose>
<simpara>If this macro is defined, then library won't use C++11 variadic templates.
Users may define this macro to make
<code><macroname>BOOST_VARIANT_ENUM_PARAMS</macroname></code>
and <code><macroname>BOOST_VARIANT_ENUM_SHIFTED_PARAMS</macroname></code> expand
to a comma-separated sequence instead of variadic templates. Define this macro if
your compiler has problems with compilation of variadic templates.
</simpara>
</purpose>
</macro>

<macro name="BOOST_VARIANT_ENUM_PARAMS" kind="functionlike">
<macro-parameter name="param"/>

Expand All @@ -58,9 +28,7 @@
</purpose>

<description>
<para> When variadic templates are available and
<code><macroname>BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES</macroname></code>
is not defined, expands to variadic template list in the following manner:
<para> Expands to variadic template list in the following manner:
<code><programlisting>
BOOST_VARIANT_ENUM_PARAMS(T) => T0, TN...
BOOST_VARIANT_ENUM_PARAMS(class T) => class T0, class... TN
Expand Down Expand Up @@ -97,9 +65,7 @@
</purpose>

<description>
<para> When variadic templates are available and
<code><macroname>BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES</macroname></code>
is not defined, expands to variadic template list in the following manner:
<para> Expands to variadic template list in the following manner:
<code><programlisting>
BOOST_VARIANT_ENUM_SHIFTED_PARAMS(T) => TN...
BOOST_VARIANT_ENUM_SHIFTED_PARAMS(class T) => class... TN
Expand Down
6 changes: 0 additions & 6 deletions doc/tutorial/advanced.xml
Original file line number Diff line number Diff line change
Expand Up @@ -407,12 +407,6 @@ assert(
</programlisting>
</para>

<para>Finally, we must note that multi visitation does not support
&quot;delayed&quot; form of
<code><functionname>apply_visitor</functionname> if
<macroname>BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES</macroname> is defined</code>.
</para>

</section>


Expand Down
95 changes: 14 additions & 81 deletions include/boost/variant/detail/apply_visitor_binary.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@
# include <boost/variant/detail/has_result_type.hpp>
#endif

#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
# include <boost/core/enable_if.hpp>
# include <boost/type_traits/is_lvalue_reference.hpp>
# include <boost/type_traits/is_same.hpp>
# include <boost/move/utility_core.hpp> // for boost::move, boost::forward
#endif
#include <boost/core/enable_if.hpp>
#include <boost/type_traits/is_lvalue_reference.hpp>
#include <boost/type_traits/is_same.hpp>
#include <utility>

namespace boost {

Expand Down Expand Up @@ -63,33 +61,20 @@ class apply_visitor_binary_invoke

public: // visitor interfaces

#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES

template <typename Value2>
typename enable_if_c<MoveSemantics && is_same<Value2, Value2>::value, result_type>::type
operator()(Value2&& value2)
{
return visitor_(::boost::move(value1_), ::boost::forward<Value2>(value2));
return visitor_(std::move(value1_), std::forward<Value2>(value2));
}

template <typename Value2>
typename disable_if_c<MoveSemantics && is_same<Value2, Value2>::value, result_type>::type
operator()(Value2&& value2)
{
return visitor_(value1_, ::boost::forward<Value2>(value2));
}

#else

template <typename Value2>
result_type
operator()(Value2& value2)
{
return visitor_(value1_, value2);
return visitor_(value1_, std::forward<Value2>(value2));
}

#endif

private:
apply_visitor_binary_invoke& operator=(const apply_visitor_binary_invoke&);
};
Expand Down Expand Up @@ -117,8 +102,6 @@ class apply_visitor_binary_unwrap

public: // visitor interfaces

#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES

template <typename Value1>
typename enable_if_c<MoveSemantics && is_same<Value1, Value1>::value, result_type>::type
operator()(Value1&& value1)
Expand All @@ -129,7 +112,7 @@ class apply_visitor_binary_unwrap
, ! ::boost::is_lvalue_reference<Value1>::value
> invoker(visitor_, value1);

return boost::apply_visitor(invoker, ::boost::move(visitable2_));
return boost::apply_visitor(invoker, std::move(visitable2_));
}

template <typename Value1>
Expand All @@ -145,23 +128,6 @@ class apply_visitor_binary_unwrap
return boost::apply_visitor(invoker, visitable2_);
}

#else

template <typename Value1>
result_type
operator()(Value1& value1)
{
apply_visitor_binary_invoke<
Visitor
, Value1
, false
> invoker(visitor_, value1);

return boost::apply_visitor(invoker, visitable2_);
}

#endif

private:
apply_visitor_binary_unwrap& operator=(const apply_visitor_binary_unwrap&);

Expand All @@ -173,8 +139,6 @@ class apply_visitor_binary_unwrap
// nonconst-visitor version:
//

#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES

template <typename Visitor, typename Visitable1, typename Visitable2>
inline typename Visitor::result_type
apply_visitor( Visitor& visitor, Visitable1&& visitable1, Visitable2&& visitable2)
Expand All @@ -183,29 +147,13 @@ apply_visitor( Visitor& visitor, Visitable1&& visitable1, Visitable2&& visitable
Visitor, Visitable2, ! ::boost::is_lvalue_reference<Visitable2>::value
> unwrapper(visitor, visitable2);

return boost::apply_visitor(unwrapper, ::boost::forward<Visitable1>(visitable1));
}

#else

template <typename Visitor, typename Visitable1, typename Visitable2>
inline typename Visitor::result_type
apply_visitor( Visitor& visitor, Visitable1& visitable1, Visitable2& visitable2)
{
::boost::detail::variant::apply_visitor_binary_unwrap<
Visitor, Visitable2, false
> unwrapper(visitor, visitable2);

return boost::apply_visitor(unwrapper, visitable1);
return boost::apply_visitor(unwrapper, std::forward<Visitable1>(visitable1));
}

#endif

//
// const-visitor version:
//

#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES

template <typename Visitor, typename Visitable1, typename Visitable2>
inline typename Visitor::result_type
Expand All @@ -215,24 +163,9 @@ apply_visitor( const Visitor& visitor , Visitable1&& visitable1 , Visitable2&& v
const Visitor, Visitable2, ! ::boost::is_lvalue_reference<Visitable2>::value
> unwrapper(visitor, visitable2);

return boost::apply_visitor(unwrapper, ::boost::forward<Visitable1>(visitable1));
return boost::apply_visitor(unwrapper, std::forward<Visitable1>(visitable1));
}

#else

template <typename Visitor, typename Visitable1, typename Visitable2>
inline typename Visitor::result_type
apply_visitor( const Visitor& visitor , Visitable1& visitable1 , Visitable2& visitable2)
{
::boost::detail::variant::apply_visitor_binary_unwrap<
const Visitor, Visitable2, false
> unwrapper(visitor, visitable2);

return boost::apply_visitor(unwrapper, visitable1);
}

#endif


#if !defined(BOOST_NO_CXX14_DECLTYPE_AUTO) && !defined(BOOST_NO_CXX11_DECLTYPE_N3276)

Expand Down Expand Up @@ -263,13 +196,13 @@ class apply_visitor_binary_invoke_cpp14
template <typename Value2>
decltype(auto) operator()(Value2&& value2, typename enable_if_c<MoveSemantics && is_same<Value2, Value2>::value, bool>::type = true)
{
return visitor_(::boost::move(value1_), ::boost::forward<Value2>(value2));
return visitor_(std::move(value1_), std::forward<Value2>(value2));
}

template <typename Value2>
decltype(auto) operator()(Value2&& value2, typename disable_if_c<MoveSemantics && is_same<Value2, Value2>::value, bool>::type = true)
{
return visitor_(value1_, ::boost::forward<Value2>(value2));
return visitor_(value1_, std::forward<Value2>(value2));
}

private:
Expand Down Expand Up @@ -301,7 +234,7 @@ class apply_visitor_binary_unwrap_cpp14
, ! ::boost::is_lvalue_reference<Value1>::value
> invoker(visitor_, value1);

return boost::apply_visitor(invoker, ::boost::move(visitable2_));
return boost::apply_visitor(invoker, std::move(visitable2_));
}

template <typename Value1>
Expand Down Expand Up @@ -333,7 +266,7 @@ inline decltype(auto) apply_visitor(Visitor& visitor, Visitable1&& visitable1, V
Visitor, Visitable2, ! ::boost::is_lvalue_reference<Visitable2>::value
> unwrapper(visitor, visitable2);

return boost::apply_visitor(unwrapper, ::boost::forward<Visitable1>(visitable1));
return boost::apply_visitor(unwrapper, std::forward<Visitable1>(visitable1));
}

template <typename Visitor, typename Visitable1, typename Visitable2>
Expand All @@ -347,7 +280,7 @@ inline decltype(auto) apply_visitor(const Visitor& visitor, Visitable1&& visitab
const Visitor, Visitable2, ! ::boost::is_lvalue_reference<Visitable2>::value
> unwrapper(visitor, visitable2);

return boost::apply_visitor(unwrapper, ::boost::forward<Visitable1>(visitable1));
return boost::apply_visitor(unwrapper, std::forward<Visitable1>(visitable1));
}


Expand Down
30 changes: 3 additions & 27 deletions include/boost/variant/detail/apply_visitor_delayed.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#include <boost/variant/detail/apply_visitor_unary.hpp>
#include <boost/variant/detail/apply_visitor_binary.hpp>
#include <boost/variant/variant_fwd.hpp> // for BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES
#include <boost/variant/variant_fwd.hpp>


#include <boost/variant/detail/has_result_type.hpp>
Expand Down Expand Up @@ -57,35 +57,13 @@ class apply_visitor_delayed_t
{
}

#if !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES)

public: // N-ary visitor interface
template <typename... Visitables>
result_type operator()(Visitables&... visitables) const
{
return apply_visitor(visitor_, visitables...);
}

#else // !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES)

public: // unary visitor interface

template <typename Visitable>
result_type operator()(Visitable& visitable) const
{
return apply_visitor(visitor_, visitable);
}

public: // binary visitor interface

template <typename Visitable1, typename Visitable2>
result_type operator()(Visitable1& visitable1, Visitable2& visitable2) const
{
return apply_visitor(visitor_, visitable1, visitable2);
}

#endif // !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES)

private:
apply_visitor_delayed_t& operator=(const apply_visitor_delayed_t&);

Expand All @@ -100,8 +78,7 @@ inline typename boost::enable_if<
return apply_visitor_delayed_t<Visitor>(visitor);
}

#if !defined(BOOST_NO_CXX14_DECLTYPE_AUTO) && !defined(BOOST_NO_CXX11_DECLTYPE_N3276) \
&& !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES)
#if !defined(BOOST_NO_CXX14_DECLTYPE_AUTO)

template <typename Visitor>
class apply_visitor_delayed_cpp14_t
Expand Down Expand Up @@ -137,8 +114,7 @@ inline typename boost::disable_if<
return apply_visitor_delayed_cpp14_t<Visitor>(visitor);
}

#endif // !defined(BOOST_NO_CXX14_DECLTYPE_AUTO) && !defined(BOOST_NO_CXX11_DECLTYPE_N3276)
// && !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES)
#endif // !defined(BOOST_NO_CXX14_DECLTYPE_AUTO)


} // namespace boost
Expand Down
Loading

0 comments on commit 7b45064

Please sign in to comment.