Skip to content

Commit

Permalink
docs: grammar traits are aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
alandefreitas committed May 27, 2024
1 parent 363a457 commit d717525
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 34 deletions.
4 changes: 2 additions & 2 deletions doc/modules/ROOT/pages/reference.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,9 @@ xref:reference:boost/urls/grammar/variant_rule.adoc[`variant_rule`]

**Type Traits**

xref:reference:boost/urls/grammar/is_charset-0c.adoc[`is_charset`]
xref:reference:boost/urls/grammar/is_charset.adoc[`is_charset`]

xref:reference:boost/urls/grammar/is_rule-0a.adoc[`is_rule`]
xref:reference:boost/urls/grammar/is_rule.adoc[`is_rule`]

| **Types**

Expand Down
6 changes: 6 additions & 0 deletions include/boost/url/detail/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@
#define BOOST_URL_IMPLEMENTATION_DEFINED(Type) __implementation_defined__
#endif

#ifndef BOOST_URL_DOCS
#define BOOST_URL_SEE_BELOW(Type) Type
#else
#define BOOST_URL_SEE_BELOW(Type) __see_below__
#endif



// avoid Boost.TypeTraits for these traits
Expand Down
33 changes: 17 additions & 16 deletions include/boost/url/grammar/charset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,22 @@ namespace boost {
namespace urls {
namespace grammar {

namespace detail
{
template<class T, class = void>
struct is_charset : std::false_type {};

template<class T>
struct is_charset<T, void_t<
decltype(
std::declval<bool&>() =
std::declval<T const&>().operator()(
std::declval<char>())
) > > : std::true_type
{
};
}

/** Alias for `std::true_type` if T satisfies <em>CharSet</em>.
This metafunction determines if the
Expand All @@ -43,23 +59,8 @@ namespace grammar {
@tparam T the type to check.
*/
#ifdef BOOST_URL_DOCS
template<class T>
using is_charset = __see_below__;
#else
template<class T, class = void>
struct is_charset : std::false_type {};

template<class T>
struct is_charset<T, void_t<
decltype(
std::declval<bool&>() =
std::declval<T const&>().operator()(
std::declval<char>())
) > > : std::true_type
{
};
#endif
using is_charset = BOOST_URL_SEE_BELOW(detail::is_charset<T>);

//------------------------------------------------

Expand Down
33 changes: 17 additions & 16 deletions include/boost/url/grammar/type_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,22 @@ namespace boost {
namespace urls {
namespace grammar {

namespace detail
{
template<class T, class = void>
struct is_rule : std::false_type {};

template<class T>
struct is_rule<T, void_t<decltype(
std::declval<system::result<typename T::value_type>&>() =
std::declval<T const&>().parse(
std::declval<char const*&>(),
std::declval<char const*>())
)>> : std::is_nothrow_copy_constructible<T>
{
};
}

/** Determine if T meets the requirements of Rule
This is an alias for `std::true_type` if
Expand All @@ -43,23 +59,8 @@ namespace grammar {
@see
@ref parse.
*/
#ifdef BOOST_URL_DOCS
template<class T>
using is_rule = __see_below__;
#else
template<class T, class = void>
struct is_rule : std::false_type {};

template<class T>
struct is_rule<T, void_t<decltype(
std::declval<system::result<typename T::value_type>&>() =
std::declval<T const&>().parse(
std::declval<char const*&>(),
std::declval<char const*>())
)>> : std::is_nothrow_copy_constructible<T>
{
};
#endif
using is_rule = BOOST_URL_SEE_BELOW(detail::is_rule<T>);

} // grammar
} // urls
Expand Down

0 comments on commit d717525

Please sign in to comment.