From d2cea1b45ab4752ac841d2e65dec169e7ed65aa0 Mon Sep 17 00:00:00 2001 From: badair Date: Thu, 14 Apr 2016 17:47:44 -0500 Subject: [PATCH] adding container operations for parameter lists, apply_return special case --- doc/callable_traits.qbk | 127 ++++++++++++++---- doc/html/callable_traits/faq.html | 82 ++++++++++- doc/html/callable_traits/headers.html | 9 ++ .../callable_traits/ref_add_member_const.html | 9 +- .../callable_traits/ref_add_member_cv.html | 9 +- .../ref_add_member_lvalue_reference.html | 13 +- .../ref_add_member_rvalue_reference.html | 9 +- .../ref_add_member_volatile.html | 9 +- doc/html/callable_traits/ref_add_varargs.html | 9 +- .../ref_apply_member_pointer.html | 16 ++- .../callable_traits/ref_apply_return.html | 7 + .../ref_can_invoke_constexpr.html | 6 +- doc/html/callable_traits/ref_clear_args.html | 99 ++++++++++++++ doc/html/callable_traits/ref_expand_args.html | 8 +- .../callable_traits/ref_push_args_back.html | 62 +++++++++ .../callable_traits/ref_push_args_front.html | 62 +++++++++ .../ref_remove_member_volatile.html | 6 +- doc/html/callable_traits/ref_result_of.html | 6 +- doc/html/index.html | 89 ++---------- doc/html/standalone_HTML.manifest | 3 + example/clear_args.cpp | 19 +++ example/push_args_back.cpp | 19 +++ example/push_args_front.cpp | 19 +++ include/callable_traits/apply_return.hpp | 17 ++- include/callable_traits/callable_traits.hpp | 3 + include/callable_traits/clear_args.hpp | 50 +++++++ .../detail/default_callable_traits.hpp | 17 +++ include/callable_traits/detail/function.hpp | 24 ++++ .../callable_traits/detail/function_cc.hpp | 18 ++- .../detail/function_object.hpp | 17 +++ .../detail/varargs_function_cc.hpp | 17 +++ .../callable_traits/detail/varargs_pmf_cc.hpp | 17 +++ include/callable_traits/push_args_back.hpp | 50 +++++++ include/callable_traits/push_args_front.hpp | 50 +++++++ 34 files changed, 844 insertions(+), 133 deletions(-) create mode 100644 doc/html/callable_traits/ref_clear_args.html create mode 100644 doc/html/callable_traits/ref_push_args_back.html create mode 100644 doc/html/callable_traits/ref_push_args_front.html create mode 100644 example/clear_args.cpp create mode 100644 example/push_args_back.cpp create mode 100644 example/push_args_front.cpp create mode 100644 include/callable_traits/clear_args.hpp create mode 100644 include/callable_traits/push_args_back.hpp create mode 100644 include/callable_traits/push_args_front.hpp diff --git a/doc/callable_traits.qbk b/doc/callable_traits.qbk index ab0c4fd..2220888 100644 --- a/doc/callable_traits.qbk +++ b/doc/callable_traits.qbk @@ -93,6 +93,7 @@ [template link_bind[][link callable_traits.ref_bind [^bind]]] [template link_can_invoke[][link callable_traits.ref_can_invoke [^can_invoke]]] [template link_can_invoke_constexpr[][link callable_traits.ref_can_invoke_constexpr [^can_invoke_constexpr]]] +[template link_clear_args[][link callable_traits.ref_clear_args [^clear_args]]] [template link_expand_args[][link callable_traits.ref_expand_args [^expand_args]]] [template link_function_type[][link callable_traits.ref_function_type [^function_type]]] [template link_has_calling_convention[][link callable_traits.ref_has_calling_convention [^has_calling_convention]]] @@ -115,6 +116,8 @@ [template link_remove_member_reference[][link callable_traits.ref_remove_member_reference [^remove_member_reference]]] [template link_remove_varargs[][link callable_traits.ref_remove_varargs [^remove_varargs]]] [template link_remove_member_volatile[][link callable_traits.ref_remove_member_volatile [^remove_member_volatile]]] +[template link_push_args_back[][link callable_traits.ref_push_args_back [^push_args_back]]] +[template link_push_args_front[][link callable_traits.ref_push_args_front [^push_args_front]]] [template link_result_of[][link callable_traits.ref_result_of [^result_of]]] [template cc_warning_rationale[] @@ -194,30 +197,6 @@ The use cases for [libname] are closely related to those of [@http://www.boost.o [intro] [endsect][/section:quick_example] -[section:reasons What makes [libname] unique?] - -[*1.] [libname] offers template aliases such as [link_remove_member_const] for manipulating function qualifiers, designed to parallel the `` aliases such as `std::remove_const_t`. - -[*2.] [libname] is designed to accept cv-qualified and ref-qualified types, which eliminates the need to prepare template argument types with metafunctions such as `std::remove_reference` and `std::decay`. This is especially useful when dealing with perfectly-forwarded parameter types in function templates. - -[*3.] [libname] is designed to comply with [invoke] rules, with one unobtrusive and beneficial deviation: [link_fn] types are compatible with all relevant type operations that do not specifically require an invocation. - -[*4.] [namespace_scoped][link_arg_at]`<2, Callable>` is more flexible than `typename boost::function_traits::arg3_type`. - -[*5.] [link_can_invoke] is used to test `INVOKE`-ability at compile-time, with value semantics. For the craziest metaprogrammers, [link_can_invoke_constexpr] does the same as `can_invoke` for [link_constexpr_constructible] types, with an added check for `constexpr`-ness - -[*6.] [link_is_constexpr] is used to check whether a [link_constexpr_constructible] type is a [link_callable] type that yields a `constexpr` result -- no arguments necessary. - -[*7.] [link_bind] is used to intercept the signature information from a `std::placeholder` expression before forwarding on to `std::bind` or `boost::bind`. This gives library writers the power to create more flexible template APIs for callable types. - -[*8.] [link_min_arity] can be used to detect the presence of default arguments on a [link_simple_fn_obj] - -[*9.] The [libname] interface mainly consists of template aliases and `constexpr std::integral_constant` functions, which are arguably preferable to `typename foo::type` and `foo::value`. While the `std::integral_constant` functions in [libname] may be a deviation from traditional type trait designs, they facilitate a metaprogramming style that uses value-semantics (a la [hana]). The functions can generally be used with either types or values, which eliminates unnecessary `decltype` usage. - -[*10.] [libname] includes optional features for the manipulation and inspection of calling conventions. These features are currently deemed experimental, because they greatly increase the test surface of [libname], are platform-specific, and are not yet fully tested on any platform. - -[endsect][/section:reasons] - [endsect][/section:introduction] @@ -478,6 +457,7 @@ The simplest way to use [libname] is to include the main header file: * [include_header [link_bind]] * [include_header [link_can_invoke]] * [include_header [link_can_invoke_constexpr]] +* [include_header [link_clear_args]] * [include_header [link_function_type]] * [include_header [link_has_calling_convention]] * [include_header [link_has_member_qualifiers]] @@ -499,6 +479,8 @@ The simplest way to use [libname] is to include the main header file: * [include_header [link_remove_member_reference]] * [include_header [link_remove_member_volatile]] * [include_header [link_remove_varargs]] +* [include_header [link_push_args_back]] +* [include_header [link_push_args_front]] * [include_header [link_result_of]] [endsect][/section:headers] @@ -573,6 +555,9 @@ For `add_calling_convention` to work as-intended, you must: * `add_member_const` aliases `int(foo::*)() const volatile` * `add_member_const` aliases `int(foo::* const &)() const` +[heading Notes] +* Any enabled calling conventions are preserved on [link_pmf] types + [heading Example] [import ../example/add_member_const.cpp] [add_member_const] @@ -605,6 +590,9 @@ For `add_calling_convention` to work as-intended, you must: * `add_member_cv` aliases `int(foo::*)() const volatile` * `add_member_cv` aliases `int(foo::* const &)() const volatile` +[heading Notes] +* Any enabled calling conventions are preserved on [link_pmf] types + [heading Example] [import ../example/add_member_cv.cpp] [add_member_cv] @@ -642,6 +630,10 @@ For `add_calling_convention` to work as-intended, you must: * `add_member_lvalue_reference` aliases `int(foo::*)() const &` * `add_member_lvalue_reference` aliases `int(foo::* const &)() &` +[heading Notes] +* Any enabled calling conventions are preserved on [link_pmf] types + +[heading Example] [import ../example/add_member_lvalue_reference.cpp] [add_member_lvalue_reference] @@ -676,6 +668,9 @@ For `add_calling_convention` to work as-intended, you must: * `add_member_rvalue_reference` aliases `int(foo::*)() const &` * `add_member_rvalue_reference` aliases `int(foo::* const &)() &&` +[heading Notes] +* Any enabled calling conventions are preserved on [link_pmf] types + [heading Example] [import ../example/add_member_rvalue_reference.cpp] [add_member_rvalue_reference] @@ -714,7 +709,10 @@ For `add_calling_convention` to work as-intended, you must: * `add_varargs` aliases `int(* const)(int, ...)` * `add_varargs` aliases `int(&)(int, ...)` * `add_varargs` aliases `int(foo::* volatile &)(...) const` - + +[heading Notes] +* Any enabled calling conventions are preserved on [link_fn_ptr] and [link_pmf] types + [heading Example] [import ../example/add_varargs.cpp] [add_varargs] @@ -748,6 +746,9 @@ For `add_calling_convention` to work as-intended, you must: * `add_member_volatile` aliases `int(foo::*)() const volatile` * `add_member_volatile` aliases `int(foo::* const &)() volatile` +[heading Notes] +* Any enabled calling conventions are preserved on [link_pmf] types + [heading Example] [import ../example/add_member_volatile.cpp] [add_member_volatile] @@ -790,6 +791,10 @@ For `add_calling_convention` to work as-intended, you must: * Let `MemberType` represent the type pointed to by `T`, such that `std::is_same>::value` is true * `apply_member_pointer` aliases `MemberType Class::* /* any pointer qualifiers on T */` +[heading Notes] +* Any enabled calling conventions are preserved on [link_pmf] types. +* Any enabled calling conventions on [link_fn] types are transferred to the aliased [link_pmf] type ([feedback]?) + [heading Example] [import ../example/apply_member_pointer.cpp] [apply_member_pointer] @@ -827,6 +832,9 @@ For `add_calling_convention` to work as-intended, you must: * the aliased type is `Return Class::* /* any qualifiers on T */`, such that: * `apply_return` becomes `char foo::* const &` +[heading Notes] +* Any enabled calling conventions are preserved on [link_fn_ptr] and [link_pmf] types. + [heading Example] [/import ../example/apply_return.cpp] [apply_return] @@ -1079,12 +1087,41 @@ For `add_calling_convention` to work as-intended, you must: [endsect] + +[section:ref_clear_args clear_args] + + namespace ``[lib_namespace]`` { + + template + using clear_args = /* implementation-defined */; + } + +[heading Constraints] +* `T` must be a [link_signature] + +[heading Behavior] +* When the constraints are violated, a substitution failure occurs +* Otherwise, `clear_args` is identical to `T`, except that the aliased type's parameter list is reduced to `void` + +[heading Notes] +* Any C-style variadics on `T` are removed by `clear_args` +* Any enabled calling conventions are preserved on pointer types + +[heading Example] +[import ../example/clear_args.cpp] +[clear_args] + +[endsect] + + + + [section:ref_expand_args expand_args] namespace ``[lib_namespace]`` { template class Container> - using expand_args = /* implementation-defined */; + using expand_args = /* implementation-defined */; } [heading Constraints] @@ -1387,6 +1424,20 @@ TODO [remove_member_volatile] [endsect] +[section:ref_push_args_back push_args_back] +TODO +[heading Example] +[import ../example/push_args_back.cpp] +[push_args_back] +[endsect] + +[section:ref_push_args_front push_args_front] +TODO +[heading Example] +[import ../example/push_args_front.cpp] +[push_args_front] +[endsect] + [section:ref_result_of result_of] TODO [heading Example] @@ -1402,6 +1453,30 @@ TODO [section:faq FAQ] +[section:reasons What makes [libname] unique?] + +[*1.] [libname] offers template aliases such as [link_remove_member_const] for manipulating function qualifiers, designed to parallel the `` aliases such as `std::remove_const_t`. + +[*2.] [libname] is designed to accept cv-qualified and ref-qualified types, which eliminates the need to prepare template argument types with metafunctions such as `std::remove_reference` and `std::decay`. This is especially useful when dealing with perfectly-forwarded parameter types in function templates. + +[*3.] [libname] is designed to comply with [invoke] rules, with one unobtrusive and beneficial deviation: [link_fn] types are compatible with all relevant type operations that do not specifically require an invocation. + +[*4.] [namespace_scoped][link_arg_at]`<2, Callable>` is more flexible than `typename boost::function_traits::arg3_type`. + +[*5.] [link_can_invoke] is used to test `INVOKE`-ability at compile-time, with value semantics. For the craziest metaprogrammers, [link_can_invoke_constexpr] does the same as `can_invoke` for [link_constexpr_constructible] types, with an added check for `constexpr`-ness + +[*6.] [link_is_constexpr] is used to check whether a [link_constexpr_constructible] type is a [link_callable] type that yields a `constexpr` result -- no arguments necessary. + +[*7.] [link_bind] is used to intercept the signature information from a `std::placeholder` expression before forwarding on to `std::bind` or `boost::bind`. This gives library writers the power to create more flexible template APIs for callable types. + +[*8.] [link_min_arity] can be used to detect the presence of default arguments on a [link_simple_fn_obj] + +[*9.] The [libname] interface mainly consists of template aliases and `constexpr std::integral_constant` functions, which are arguably preferable to `typename foo::type` and `foo::value`. While the `std::integral_constant` functions in [libname] may be a deviation from traditional type trait designs, they facilitate a metaprogramming style that uses value-semantics (a la [hana]). The functions can generally be used with either types or values, which eliminates unnecessary `decltype` usage. + +[*10.] [libname] includes optional features for the manipulation and inspection of calling conventions. These features are currently deemed experimental, because they greatly increase the test surface of [libname], are platform-specific, and are not yet fully tested on any platform. + +[endsect][/section:reasons] + [section Why does [namespace_scoped][^args] alias a [^std::tuple]?] Boost contains a handful of excellent type containers. However, I wanted [libname] to only use the standard headers, so `` was my only option under that limitation. diff --git a/doc/html/callable_traits/faq.html b/doc/html/callable_traits/faq.html index dd5cebb..f28a8e2 100644 --- a/doc/html/callable_traits/faq.html +++ b/doc/html/callable_traits/faq.html @@ -26,8 +26,86 @@

FAQ

- + +
+ +

+ 1. CallableTraits offers + template aliases such as remove_member_const + for manipulating function qualifiers, designed to parallel the <type_traits> aliases such as std::remove_const_t. +

+

+ 2. CallableTraits is + designed to accept cv-qualified and ref-qualified types, which eliminates + the need to prepare template argument types with metafunctions such as std::remove_reference + and std::decay. This is especially useful when dealing + with perfectly-forwarded parameter types in function templates. +

+

+ 3. CallableTraits is + designed to comply with INVOKE + rules, with one unobtrusive and beneficial deviation: Function types are compatible with all relevant + type operations that do not specifically require an invocation. +

+

+ 4. callable_traits::arg_at<2, + Callable> + is more flexible than typename boost::function_traits<Callable>::arg3_type. +

+

+ 5. can_invoke + is used to test INVOKE-ability + at compile-time, with value semantics. For the craziest metaprogrammers, + can_invoke_constexpr + does the same as can_invoke + for ConstexprDefaultConstructible types, with an + added check for constexpr-ness +

+

+ 6. is_constexpr + is used to check whether a ConstexprDefaultConstructible type is a Callable + type that yields a constexpr + result -- no arguments necessary. +

+

+ 7. bind + is used to intercept the signature information from a std::placeholder + expression before forwarding on to std::bind + or boost::bind. This gives library writers the power + to create more flexible template APIs for callable types. +

+

+ 8. min_arity + can be used to detect the presence of default arguments on a SimpleFunctionObject +

+

+ 9. The CallableTraits + interface mainly consists of template aliases and constexpr + std::integral_constant functions, which are + arguably preferable to typename foo::type + and foo::value. While the std::integral_constant + functions in CallableTraits may be a deviation from traditional + type trait designs, they facilitate a metaprogramming style that uses value-semantics + (a la Boost.Hana). + The functions can generally be used with either types or values, which eliminates + unnecessary decltype usage. +

+

+ 10. CallableTraits includes + optional features for the manipulation and inspection of calling conventions. + These features are currently deemed experimental, because they greatly increase + the test surface of CallableTraits, are platform-specific, + and are not yet fully tested on any platform. +

+

Why diff --git a/doc/html/callable_traits/headers.html b/doc/html/callable_traits/headers.html index c5baadb..79d99cc 100644 --- a/doc/html/callable_traits/headers.html +++ b/doc/html/callable_traits/headers.html @@ -84,6 +84,9 @@
  • #include<callable_traits/can_invoke_constexpr.hpp>
  • +
  • + #include<callable_traits/clear_args.hpp> +
  • #include<callable_traits/function_type.hpp>
  • @@ -147,6 +150,12 @@
  • #include<callable_traits/remove_varargs.hpp>
  • +
  • + #include<callable_traits/push_args_back.hpp> +
  • +
  • + #include<callable_traits/push_args_front.hpp> +
  • #include<callable_traits/result_of.hpp>
  • diff --git a/doc/html/callable_traits/ref_add_member_const.html b/doc/html/callable_traits/ref_add_member_const.html index 2152b0b..09b6b3a 100644 --- a/doc/html/callable_traits/ref_add_member_const.html +++ b/doc/html/callable_traits/ref_add_member_const.html @@ -66,6 +66,13 @@

    + Notes +

    +
    +

    + Example

    #include <type_traits>
    @@ -114,7 +121,7 @@
     }
     

    - + See Also

    diff --git a/doc/html/callable_traits/ref_add_member_cv.html b/doc/html/callable_traits/ref_add_member_cv.html index bdf5ce1..4193751 100644 --- a/doc/html/callable_traits/ref_add_member_cv.html +++ b/doc/html/callable_traits/ref_add_member_cv.html @@ -71,6 +71,13 @@

    + Notes +

    +
    +

    + Example

    #include <type_traits>
    @@ -119,7 +126,7 @@
     }
     

    - + See Also

    diff --git a/doc/html/callable_traits/ref_add_member_lvalue_reference.html b/doc/html/callable_traits/ref_add_member_lvalue_reference.html index 7455c9d..7d89a1b 100644 --- a/doc/html/callable_traits/ref_add_member_lvalue_reference.html +++ b/doc/html/callable_traits/ref_add_member_lvalue_reference.html @@ -77,6 +77,17 @@
    +

    + + Notes +

    +
    +

    + + Example +

    #include <type_traits>
     #include <callable_traits/add_member_lvalue_reference.hpp>
     
    @@ -126,7 +137,7 @@
     }
     

    - + See Also

      diff --git a/doc/html/callable_traits/ref_add_member_rvalue_reference.html b/doc/html/callable_traits/ref_add_member_rvalue_reference.html index 3354e63..8122345 100644 --- a/doc/html/callable_traits/ref_add_member_rvalue_reference.html +++ b/doc/html/callable_traits/ref_add_member_rvalue_reference.html @@ -79,6 +79,13 @@

    + Notes +

    +
    +

    + Example

    #include <type_traits>
    @@ -130,7 +137,7 @@
     }
     

    - + See Also

      diff --git a/doc/html/callable_traits/ref_add_member_volatile.html b/doc/html/callable_traits/ref_add_member_volatile.html index adceef4..7130e73 100644 --- a/doc/html/callable_traits/ref_add_member_volatile.html +++ b/doc/html/callable_traits/ref_add_member_volatile.html @@ -66,6 +66,13 @@

    + Notes +

    +
    +

    + Example

    #include <type_traits>
    @@ -114,7 +121,7 @@
     }
     

    - + See Also

    diff --git a/doc/html/callable_traits/ref_add_varargs.html b/doc/html/callable_traits/ref_add_varargs.html index a28a7f1..99ce934 100644 --- a/doc/html/callable_traits/ref_add_varargs.html +++ b/doc/html/callable_traits/ref_add_varargs.html @@ -88,6 +88,13 @@

    + Notes +

    +
    +

    + Example

    #include <type_traits>
    @@ -143,7 +150,7 @@
     }
     

    - + See Also

    diff --git a/doc/html/callable_traits/ref_apply_member_pointer.html b/doc/html/callable_traits/ref_apply_member_pointer.html index 03e51ab..11a0c96 100644 --- a/doc/html/callable_traits/ref_apply_member_pointer.html +++ b/doc/html/callable_traits/ref_apply_member_pointer.html @@ -106,6 +106,20 @@

    + Notes +

    +
    +

    + Example

    #include <type_traits>
    @@ -157,7 +171,7 @@
     }
     

    - + See Also

    diff --git a/doc/html/callable_traits/ref_apply_return.html b/doc/html/callable_traits/ref_apply_return.html index 5fa1cd4..0862595 100644 --- a/doc/html/callable_traits/ref_apply_return.html +++ b/doc/html/callable_traits/ref_apply_return.html @@ -98,6 +98,13 @@

    + Notes +

    +
    +

    + Example

    diff --git a/doc/html/callable_traits/ref_can_invoke_constexpr.html b/doc/html/callable_traits/ref_can_invoke_constexpr.html index 5ee0fce..50aa5d3 100644 --- a/doc/html/callable_traits/ref_can_invoke_constexpr.html +++ b/doc/html/callable_traits/ref_can_invoke_constexpr.html @@ -7,7 +7,7 @@ - + @@ -20,7 +20,7 @@


    -PrevUpHomeNext +PrevUpHomeNext

    @@ -248,7 +248,7 @@
    -PrevUpHomeNext +PrevUpHomeNext
    diff --git a/doc/html/callable_traits/ref_clear_args.html b/doc/html/callable_traits/ref_clear_args.html new file mode 100644 index 0000000..397c45a --- /dev/null +++ b/doc/html/callable_traits/ref_clear_args.html @@ -0,0 +1,99 @@ + + + +clear_args + + + + + + + + + + + + + + + +
    Boost C++ LibrariesHomeLibrariesPeopleFAQMore
    +
    +
    +PrevUpHomeNext +
    +
    + +
    namespace callable_traits {
    +
    +        template<typename T>
    +        using clear_args = /* implementation-defined */;
    +    }
    +
    +

    + + Constraints +

    +
    +

    + + Behavior +

    +
      +
    • + When the constraints are violated, a substitution failure occurs +
    • +
    • + Otherwise, clear_args<T> + is identical to T, except + that the aliased type's parameter list is reduced to void +
    • +
    +

    + + Notes +

    +
      +
    • + Any C-style variadics on T + are removed by clear_args<T> +
    • +
    • + Any enabled calling conventions are preserved on pointer types +
    • +
    +

    + + Example +

    +
    #include <callable_traits/clear_args.hpp>
    +
    +namespace ct = callable_traits;
    +
    +int main() {
    +
    +    using f = void(int, char);
    +    using cleared = ct::clear_args<f>;
    +    using expect = void();
    +    static_assert(std::is_same<cleared, expect>::value, "");
    +}
    +
    +
    + + + +
    +
    +
    +PrevUpHomeNext +
    + + diff --git a/doc/html/callable_traits/ref_expand_args.html b/doc/html/callable_traits/ref_expand_args.html index 139a2fc..57d864d 100644 --- a/doc/html/callable_traits/ref_expand_args.html +++ b/doc/html/callable_traits/ref_expand_args.html @@ -6,7 +6,7 @@ - + @@ -20,7 +20,7 @@
    -PrevUpHomeNext +PrevUpHomeNext

    @@ -29,7 +29,7 @@
    namespace callable_traits {
     
             template<typename T, template<class...> class Container>
    -            using expand_args = /* implementation-defined */;
    +        using expand_args = /* implementation-defined */;
         }
     

    @@ -128,7 +128,7 @@
    -PrevUpHomeNext +PrevUpHomeNext
    diff --git a/doc/html/callable_traits/ref_push_args_back.html b/doc/html/callable_traits/ref_push_args_back.html new file mode 100644 index 0000000..cf63cfe --- /dev/null +++ b/doc/html/callable_traits/ref_push_args_back.html @@ -0,0 +1,62 @@ + + + +push_args_back + + + + + + + + + + + + + + + +
    Boost C++ LibrariesHomeLibrariesPeopleFAQMore
    +
    +
    +PrevUpHomeNext +
    +
    + +

    + TODO +

    +

    + + Example +

    +
    #include <callable_traits/push_args_back.hpp>
    +
    +namespace ct = callable_traits;
    +
    +int main() {
    +
    +    using f = void(int, char);
    +    using test = ct::push_args_back<f, long, void*>;
    +    using expect = void(int, char, long, void*);
    +    static_assert(std::is_same<test, expect>::value, "");
    +}
    +
    +
    + + + +
    +
    +
    +PrevUpHomeNext +
    + + diff --git a/doc/html/callable_traits/ref_push_args_front.html b/doc/html/callable_traits/ref_push_args_front.html new file mode 100644 index 0000000..55c20bf --- /dev/null +++ b/doc/html/callable_traits/ref_push_args_front.html @@ -0,0 +1,62 @@ + + + +push_args_front + + + + + + + + + + + + + + + +
    Boost C++ LibrariesHomeLibrariesPeopleFAQMore
    +
    +
    +PrevUpHomeNext +
    +
    + +

    + TODO +

    +

    + + Example +

    +
    #include <callable_traits/push_args_front.hpp>
    +
    +namespace ct = callable_traits;
    +
    +int main() {
    +
    +    using f = void(int, char);
    +    using test = ct::push_args_front<f, long, void*>;
    +    using expect = void(long, void*, int, char);
    +    static_assert(std::is_same<test, expect>::value, "");
    +}
    +
    +
    + + + +
    +
    +
    +PrevUpHomeNext +
    + + diff --git a/doc/html/callable_traits/ref_remove_member_volatile.html b/doc/html/callable_traits/ref_remove_member_volatile.html index 94ca22e..18aa936 100644 --- a/doc/html/callable_traits/ref_remove_member_volatile.html +++ b/doc/html/callable_traits/ref_remove_member_volatile.html @@ -7,7 +7,7 @@ - + @@ -20,7 +20,7 @@

    -PrevUpHomeNext +PrevUpHomeNext

    @@ -47,7 +47,7 @@
    -PrevUpHomeNext +PrevUpHomeNext
    diff --git a/doc/html/callable_traits/ref_result_of.html b/doc/html/callable_traits/ref_result_of.html index e89b973..b26b1a2 100644 --- a/doc/html/callable_traits/ref_result_of.html +++ b/doc/html/callable_traits/ref_result_of.html @@ -6,7 +6,7 @@ - + @@ -20,7 +20,7 @@
    -PrevUpHomeNext +PrevUpHomeNext

    @@ -72,7 +72,7 @@
    -PrevUpHomeNext +PrevUpHomeNext
    diff --git a/doc/html/index.html b/doc/html/index.html index 608e1b6..a245c1e 100644 --- a/doc/html/index.html +++ b/doc/html/index.html @@ -44,8 +44,6 @@
    Prerequisite Topics
    Motivation
    Quick Example
    -
    What makes CallableTraits - unique?
    Example: std::function sugar
    @@ -89,6 +87,7 @@
    bind
    can_invoke
    can_invoke_constexpr
    +
    clear_args
    expand_args
    function_type
    has_calling_convention
    @@ -111,10 +110,16 @@
    remove_member_reference
    remove_varargs
    remove_member_volatile
    +
    push_args_back
    +
    push_args_front
    result_of
    FAQ
    -
    Why - does callable_traits::args alias a std::tuple?
    +
    +
    What makes CallableTraits + unique?
    +
    Why + does callable_traits::args alias a std::tuple?
    +
    Acknowledgements
    Contact
    @@ -127,8 +132,6 @@
    Prerequisite Topics
    Motivation
    Quick Example
    -
    What makes CallableTraits - unique?

    CallableTraits is a cross-platform C++14 library for the @@ -513,80 +516,6 @@ }

    -
    - -

    - 1. CallableTraits offers - template aliases such as remove_member_const - for manipulating function qualifiers, designed to parallel the <type_traits> aliases such as std::remove_const_t. -

    -

    - 2. CallableTraits is - designed to accept cv-qualified and ref-qualified types, which eliminates - the need to prepare template argument types with metafunctions such as std::remove_reference - and std::decay. This is especially useful when dealing - with perfectly-forwarded parameter types in function templates. -

    -

    - 3. CallableTraits is - designed to comply with INVOKE - rules, with one unobtrusive and beneficial deviation: Function types are compatible with all relevant - type operations that do not specifically require an invocation. -

    -

    - 4. callable_traits::arg_at<2, - Callable> - is more flexible than typename boost::function_traits<Callable>::arg3_type. -

    -

    - 5. can_invoke - is used to test INVOKE-ability - at compile-time, with value semantics. For the craziest metaprogrammers, - can_invoke_constexpr - does the same as can_invoke - for ConstexprDefaultConstructible types, with an - added check for constexpr-ness -

    -

    - 6. is_constexpr - is used to check whether a ConstexprDefaultConstructible type is a Callable - type that yields a constexpr - result -- no arguments necessary. -

    -

    - 7. bind - is used to intercept the signature information from a std::placeholder - expression before forwarding on to std::bind - or boost::bind. This gives library writers the power - to create more flexible template APIs for callable types. -

    -

    - 8. min_arity - can be used to detect the presence of default arguments on a SimpleFunctionObject -

    -

    - 9. The CallableTraits - interface mainly consists of template aliases and constexpr - std::integral_constant functions, which are - arguably preferable to typename foo::type - and foo::value. While the std::integral_constant - functions in CallableTraits may be a deviation from traditional - type trait designs, they facilitate a metaprogramming style that uses value-semantics - (a la Boost.Hana). - The functions can generally be used with either types or values, which eliminates - unnecessary decltype usage. -

    -

    - 10. CallableTraits includes - optional features for the manipulation and inspection of calling conventions. - These features are currently deemed experimental, because they greatly increase - the test surface of CallableTraits, are platform-specific, - and are not yet fully tested on any platform. -

    -
    diff --git a/doc/html/standalone_HTML.manifest b/doc/html/standalone_HTML.manifest index 59639f5..ff5f1c8 100644 --- a/doc/html/standalone_HTML.manifest +++ b/doc/html/standalone_HTML.manifest @@ -18,6 +18,7 @@ callable_traits/ref_arity.html callable_traits/ref_bind.html callable_traits/ref_can_invoke.html callable_traits/ref_can_invoke_constexpr.html +callable_traits/ref_clear_args.html callable_traits/ref_expand_args.html callable_traits/ref_function_type.html callable_traits/ref_has_calling_convention.html @@ -40,6 +41,8 @@ callable_traits/ref_remove_member_pointer.html callable_traits/ref_remove_member_reference.html callable_traits/ref_remove_varargs.html callable_traits/ref_remove_member_volatile.html +callable_traits/ref_push_args_back.html +callable_traits/ref_push_args_front.html callable_traits/ref_result_of.html callable_traits/faq.html callable_traits/acknowledgements.html diff --git a/example/clear_args.cpp b/example/clear_args.cpp new file mode 100644 index 0000000..2867abc --- /dev/null +++ b/example/clear_args.cpp @@ -0,0 +1,19 @@ +/*<- +Copyright Barrett Adair 2016 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http ://boost.org/LICENSE_1_0.txt) +->*/ + +//[ clear_args +#include + +namespace ct = callable_traits; + +int main() { + + using f = void(int, char); + using cleared = ct::clear_args; + using expect = void(); + static_assert(std::is_same::value, ""); +} +//] diff --git a/example/push_args_back.cpp b/example/push_args_back.cpp new file mode 100644 index 0000000..7e15752 --- /dev/null +++ b/example/push_args_back.cpp @@ -0,0 +1,19 @@ +/*<- +Copyright Barrett Adair 2016 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http ://boost.org/LICENSE_1_0.txt) +->*/ + +//[ push_args_back +#include + +namespace ct = callable_traits; + +int main() { + + using f = void(int, char); + using test = ct::push_args_back; + using expect = void(int, char, long, void*); + static_assert(std::is_same::value, ""); +} +//] diff --git a/example/push_args_front.cpp b/example/push_args_front.cpp new file mode 100644 index 0000000..56f0276 --- /dev/null +++ b/example/push_args_front.cpp @@ -0,0 +1,19 @@ +/*<- +Copyright Barrett Adair 2016 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http ://boost.org/LICENSE_1_0.txt) +->*/ + +//[ push_args_front +#include + +namespace ct = callable_traits; + +int main() { + + using f = void(int, char); + using test = ct::push_args_front; + using expect = void(long, void*, int, char); + static_assert(std::is_same::value, ""); +} +//] diff --git a/include/callable_traits/apply_return.hpp b/include/callable_traits/apply_return.hpp index 0e38b0f..ba68b8c 100644 --- a/include/callable_traits/apply_return.hpp +++ b/include/callable_traits/apply_return.hpp @@ -23,13 +23,24 @@ namespace callable_traits { "callable_traits::apply_return is " "not a meaningful operation for this T."); }; + + template + struct apply_return_t { + using type = typename detail::traits::template apply_return; + }; + + //special case + template + struct apply_return_t, R> { + using type = R(Args...); + }; } namespace permissive { template using apply_return = detail::fallback_if_invalid< - typename detail::traits::template apply_return, + typename detail::apply_return_t::type, T>; } @@ -37,13 +48,13 @@ namespace callable_traits { template using apply_return = detail::fail_if_invalid< - typename detail::traits::template apply_return, + typename detail::apply_return_t::type, detail::apply_return_error>; } template using apply_return = detail::fail_if_invalid< - typename detail::traits::template apply_return, + typename detail::apply_return_t::type, detail::apply_return_error>; } diff --git a/include/callable_traits/callable_traits.hpp b/include/callable_traits/callable_traits.hpp index 8d5844f..5bb69ae 100644 --- a/include/callable_traits/callable_traits.hpp +++ b/include/callable_traits/callable_traits.hpp @@ -25,6 +25,7 @@ Distributed under the Boost Software License, Version 1.0. #include #include #include +#include #include #include #include @@ -47,6 +48,8 @@ Distributed under the Boost Software License, Version 1.0. #include #include #include +#include +#include #include #endif diff --git a/include/callable_traits/clear_args.hpp b/include/callable_traits/clear_args.hpp new file mode 100644 index 0000000..e123483 --- /dev/null +++ b/include/callable_traits/clear_args.hpp @@ -0,0 +1,50 @@ +/*! +@file + +@copyright Barrett Adair 2015 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +*/ + +#ifndef CALLABLE_TRAITS_CLEAR_ARGS_HPP +#define CALLABLE_TRAITS_CLEAR_ARGS_HPP + +#include + +namespace callable_traits { + + namespace detail { + + template + struct clear_args_error { + + static_assert(Sfinae, + "callable_traits::clear_args is " + "not a meaningful operation for this T."); + }; + } + + namespace permissive { + + template + using clear_args = detail::fallback_if_invalid< + typename detail::traits::clear_args, + T>; + } + + namespace verbose { + + template + using clear_args = detail::fail_if_invalid< + typename detail::traits::clear_args, + detail::clear_args_error>; + } + + template + using clear_args = detail::fail_if_invalid< + typename detail::traits::clear_args, + detail::clear_args_error>; +} + +#endif //CALLABLE_TRAITS_CLEAR_ARGS_HPP diff --git a/include/callable_traits/detail/default_callable_traits.hpp b/include/callable_traits/detail/default_callable_traits.hpp index 94d1dfd..533d5a7 100644 --- a/include/callable_traits/detail/default_callable_traits.hpp +++ b/include/callable_traits/detail/default_callable_traits.hpp @@ -154,6 +154,23 @@ namespace callable_traits { // Expands the argument types into a template template class Container> using expand_args = invalid_type; + + using clear_args = invalid_type; + + template + using push_args_front = invalid_type; + + template + using push_args_back = invalid_type; + + template + using pop_args_front = invalid_type; + + template + using pop_args_back = invalid_type; + + template + using insert_args = invalid_type; }; } } diff --git a/include/callable_traits/detail/function.hpp b/include/callable_traits/detail/function.hpp index 935d2bc..f55d3bb 100644 --- a/include/callable_traits/detail/function.hpp +++ b/include/callable_traits/detail/function.hpp @@ -77,6 +77,14 @@ struct function \ template class Container> \ using expand_args = Container; \ + \ + using clear_args = Return() QUAL; \ + \ + template \ + using push_args_front = Return(NewArgs..., Args...) QUAL; \ + \ + template \ + using push_args_back = Return(Args..., NewArgs...) QUAL; \ }; \ \ template \ @@ -133,6 +141,14 @@ struct function \ template class Container> \ using expand_args = Container; \ + \ + using clear_args = Return() QUAL; \ + \ + template \ + using push_args_front = Return(NewArgs..., Args..., ...) QUAL; \ + \ + template \ + using push_args_back = Return(Args..., NewArgs..., ...) QUAL; \ } \ /**/ @@ -241,6 +257,14 @@ namespace callable_traits { template using apply_return = typename base::template apply_return&; + + using clear_args = typename base::clear_args&; + + template + using push_args_front = typename base::template push_args_front&; + + template + using push_args_back = typename base::template push_args_back&; }; template diff --git a/include/callable_traits/detail/function_cc.hpp b/include/callable_traits/detail/function_cc.hpp index c8cafcc..9399d9e 100644 --- a/include/callable_traits/detail/function_cc.hpp +++ b/include/callable_traits/detail/function_cc.hpp @@ -60,7 +60,21 @@ struct function::type; - template class Container> - using expand_args = Container; + using clear_args = typename copy_cvr< + CALLABLE_TRAITS_ST Return(CALLABLE_TRAITS_CC *)(), + OriginalType + >::type; + + template + using push_args_front = typename copy_cvr< + CALLABLE_TRAITS_ST Return(CALLABLE_TRAITS_CC *)(NewArgs..., Args...), + OriginalType + >::type; + + template + using push_args_back = typename copy_cvr< + CALLABLE_TRAITS_ST Return(CALLABLE_TRAITS_CC *)(Args..., NewArgs...), + OriginalType + >::type; }; diff --git a/include/callable_traits/detail/function_object.hpp b/include/callable_traits/detail/function_object.hpp index 1ea79f8..4c7aa47 100644 --- a/include/callable_traits/detail/function_object.hpp +++ b/include/callable_traits/detail/function_object.hpp @@ -50,6 +50,23 @@ namespace callable_traits { template using apply_return = invalid_type; + using clear_args = invalid_type; + + template + using push_args_front = invalid_type; + + template + using push_args_back = invalid_type; + + template + using pop_args_front = invalid_type; + + template + using pop_args_back = invalid_type; + + template + using insert_args = invalid_type; + using remove_member_reference = invalid_type; using add_member_lvalue_reference = invalid_type; using add_member_rvalue_reference = invalid_type; diff --git a/include/callable_traits/detail/varargs_function_cc.hpp b/include/callable_traits/detail/varargs_function_cc.hpp index 8878256..2a680d0 100644 --- a/include/callable_traits/detail/varargs_function_cc.hpp +++ b/include/callable_traits/detail/varargs_function_cc.hpp @@ -65,5 +65,22 @@ struct function class Container> using expand_args = Container; + + using clear_args = typename copy_cvr< + CALLABLE_TRAITS_ST Return(CALLABLE_TRAITS_VARARGS_CC *)(), + OriginalType + >::type; + + template + using push_args_front = typename copy_cvr< + CALLABLE_TRAITS_ST Return(CALLABLE_TRAITS_VARARGS_CC *)(NewArgs..., Args..., ...), + OriginalType + >::type; + + template + using push_args_back = typename copy_cvr< + CALLABLE_TRAITS_ST Return(CALLABLE_TRAITS_VARARGS_CC *)(Args..., NewArgs..., ...), + OriginalType + >::type; }; diff --git a/include/callable_traits/detail/varargs_pmf_cc.hpp b/include/callable_traits/detail/varargs_pmf_cc.hpp index 33ce69e..27a336b 100644 --- a/include/callable_traits/detail/varargs_pmf_cc.hpp +++ b/include/callable_traits/detail/varargs_pmf_cc.hpp @@ -111,6 +111,23 @@ struct pmf class Container> \ using expand_args = Container; \ + \ + using clear_args = typename copy_cvr< \ + Return(CALLABLE_TRAITS_VARARGS_CC T::*)() QUAL, \ + OriginalType \ + >::type; \ + \ + template \ + using push_args_front = typename copy_cvr< \ + Return(CALLABLE_TRAITS_VARARGS_CC T::*)(NewArgs..., Args..., ...) QUAL, \ + OriginalType \ + >::type; \ + \ + template \ + using push_args_back = typename copy_cvr< \ + Return(CALLABLE_TRAITS_VARARGS_CC T::*)(Args..., NewArgs..., ...) QUAL, \ + OriginalType \ + >::type; \ } \ /**/ diff --git a/include/callable_traits/push_args_back.hpp b/include/callable_traits/push_args_back.hpp new file mode 100644 index 0000000..0e0d3bd --- /dev/null +++ b/include/callable_traits/push_args_back.hpp @@ -0,0 +1,50 @@ +/*! +@file + +@copyright Barrett Adair 2015 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +*/ + +#ifndef CALLABLE_TRAITS_PUSH_ARGS_BACK_HPP +#define CALLABLE_TRAITS_PUSH_ARGS_BACK_HPP + +#include + +namespace callable_traits { + + namespace detail { + + template + struct push_args_back_error { + + static_assert(Sfinae, + "callable_traits::push_args_back is " + "not a meaningful operation for this T."); + }; + } + + namespace permissive { + + template + using push_args_back = detail::fallback_if_invalid< + typename detail::traits::template push_args_back, + T>; + } + + namespace verbose { + + template + using push_args_back = detail::fail_if_invalid< + typename detail::traits::template push_args_back, + detail::push_args_back_error>; + } + + template + using push_args_back = detail::fail_if_invalid< + typename detail::traits::template push_args_back, + detail::push_args_back_error>; +} + +#endif //CALLABLE_TRAITS_PUSH_ARGS_BACK_HPP diff --git a/include/callable_traits/push_args_front.hpp b/include/callable_traits/push_args_front.hpp new file mode 100644 index 0000000..1fef238 --- /dev/null +++ b/include/callable_traits/push_args_front.hpp @@ -0,0 +1,50 @@ +/*! +@file + +@copyright Barrett Adair 2015 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +*/ + +#ifndef CALLABLE_TRAITS_PUSH_ARGS_FRONT_HPP +#define CALLABLE_TRAITS_PUSH_ARGS_FRONT_HPP + +#include + +namespace callable_traits { + + namespace detail { + + template + struct push_args_front_error { + + static_assert(Sfinae, + "callable_traits::push_args_front is " + "not a meaningful operation for this T."); + }; + } + + namespace permissive { + + template + using push_args_front = detail::fallback_if_invalid< + typename detail::traits::template push_args_front, + T>; + } + + namespace verbose { + + template + using push_args_front = detail::fail_if_invalid< + typename detail::traits::template push_args_front, + detail::push_args_front_error>; + } + + template + using push_args_front = detail::fail_if_invalid< + typename detail::traits::template push_args_front, + detail::push_args_front_error>; +} + +#endif //CALLABLE_TRAITS_PUSH_ARGS_FRONT_HPP