From 3835f31d389af1989a4839dfe15f4a350b8cdc1d Mon Sep 17 00:00:00 2001
From: badair
Date: Wed, 18 May 2016 01:27:29 -0500
Subject: [PATCH] removing all features for bind expressions
bind parser code is lumped into a single file
[here](https://github.com/badair/bind_parser/blob/master/bind_parser.hpp)
This removes over 1000 lines of code from CallableTraits.
---
doc/callable_traits.qbk | 85 +-----
doc/html/callable_traits/compatibility.html | 12 -
.../example_std_function_sugar.html | 191 ------------
doc/html/callable_traits/faq.html | 10 +-
doc/html/callable_traits/glossary.html | 9 -
doc/html/callable_traits/headers.html | 3 -
doc/html/callable_traits/ref_arg_at.html | 19 --
doc/html/callable_traits/ref_args.html | 31 --
doc/html/callable_traits/ref_arity.html | 6 +-
doc/html/callable_traits/ref_bind.html | 286 ------------------
doc/html/callable_traits/ref_expand_args.html | 3 -
.../callable_traits/ref_function_type.html | 28 --
.../callable_traits/ref_is_invokable.html | 6 +-
doc/html/callable_traits/ref_result_of.html | 6 +-
.../callable_traits_interface_example.html | 7 +-
doc/html/index.html | 8 -
doc/html/standalone_HTML.manifest | 2 -
doc/make_function_example.qbk | 20 --
example/bind_1.cpp | 88 ------
example/bind_2.cpp | 67 ----
example/interface_example.cpp | 1 +
example/make_function.hpp | 64 ----
example/make_function_example.cpp | 54 ----
include/callable_traits/bind.hpp | 52 ----
include/callable_traits/callable_traits.hpp | 1 -
include/callable_traits/detail/best_match.hpp | 161 ----------
.../detail/bind_expression.hpp | 196 ------------
.../detail/bind_expression_parser.hpp | 147 ---------
.../detail/bind_expression_traits.hpp | 49 ---
.../detail/categorize_bind_arg.hpp | 64 ----
.../detail/function_object.hpp | 5 +-
.../detail/fwd/bind_expression_fwd.hpp | 21 --
.../detail/fwd/bind_expression_parser_fwd.hpp | 21 --
.../detail/is_constexpr_impl.hpp | 2 +-
.../detail/is_invokable_constexpr_impl.hpp | 10 +-
.../detail/is_invokable_impl.hpp | 4 +-
.../callable_traits/detail/placeholder.hpp | 114 -------
.../detail/required_definitions.hpp | 1 -
include/callable_traits/detail/traits.hpp | 2 -
.../callable_traits/detail/tuple_group_by.hpp | 122 --------
include/callable_traits/detail/tuple_sort.hpp | 111 -------
.../detail/unguarded/function.hpp | 2 +-
include/callable_traits/detail/utility.hpp | 17 +-
include/callable_traits/is_like_function.hpp | 3 +-
test/bind_1.cpp | 154 ----------
test/bind_2.cpp | 147 ---------
test/detail/best_match.cpp | 43 ---
test/detail/flatten_bind_expressions.cpp | 79 -----
48 files changed, 38 insertions(+), 2496 deletions(-)
delete mode 100644 doc/html/callable_traits/example_std_function_sugar.html
delete mode 100644 doc/html/callable_traits/ref_bind.html
delete mode 100644 doc/make_function_example.qbk
delete mode 100644 example/bind_1.cpp
delete mode 100644 example/bind_2.cpp
delete mode 100644 example/make_function.hpp
delete mode 100644 example/make_function_example.cpp
delete mode 100644 include/callable_traits/bind.hpp
delete mode 100644 include/callable_traits/detail/best_match.hpp
delete mode 100644 include/callable_traits/detail/bind_expression.hpp
delete mode 100644 include/callable_traits/detail/bind_expression_parser.hpp
delete mode 100644 include/callable_traits/detail/bind_expression_traits.hpp
delete mode 100644 include/callable_traits/detail/categorize_bind_arg.hpp
delete mode 100644 include/callable_traits/detail/fwd/bind_expression_fwd.hpp
delete mode 100644 include/callable_traits/detail/fwd/bind_expression_parser_fwd.hpp
delete mode 100644 include/callable_traits/detail/placeholder.hpp
delete mode 100644 include/callable_traits/detail/tuple_group_by.hpp
delete mode 100644 include/callable_traits/detail/tuple_sort.hpp
delete mode 100644 test/bind_1.cpp
delete mode 100644 test/bind_2.cpp
delete mode 100644 test/detail/best_match.cpp
delete mode 100644 test/detail/flatten_bind_expressions.cpp
diff --git a/doc/callable_traits.qbk b/doc/callable_traits.qbk
index 2891ccb..0407a59 100644
--- a/doc/callable_traits.qbk
+++ b/doc/callable_traits.qbk
@@ -55,7 +55,6 @@
[template concept_simple_invokable[][role green SimpleInvokable]]
[template concept_callable[][role green Callable]]
[template concept_invokable[][role green Invokable]]
-[template concept_bind_expression[][role green BindExpression]]
[template concept_signature[][role green Signature]]
[template concept_constexpr_constructible[][role green ConstexprDefaultConstructible]]
[template concept_cc_tag[][role green CallingConventionTag]]
@@ -76,7 +75,6 @@
[template link_simple_invokable[][link callable_traits.glossary.ref_simple_invokable [concept_simple_invokable]]]
[template link_callable[][link callable_traits.glossary.ref_callable [concept_callable]]]
[template link_invokable[][link callable_traits.glossary.ref_invokable [concept_invokable]]]
-[template link_bind_expression[][link callable_traits.glossary.ref_bind_expression [concept_bind_expression]]]
[template link_signature[][link callable_traits.glossary.ref_signature [concept_signature]]]
[template link_constexpr_constructible[][link callable_traits.glossary.ref_constexpr_constructible [concept_constexpr_constructible]]]
[template link_cc_tag[][link callable_traits.glossary.ref_cc_tag [concept_cc_tag]]]
@@ -94,7 +92,6 @@
[template link_arg_at[][link callable_traits.ref_arg_at [^arg_at]]]
[template link_args[][link callable_traits.ref_args [^args]]]
[template link_arity[][link callable_traits.ref_arity [^arity]]]
-[template link_bind[][link callable_traits.ref_bind [^bind]]]
[template link_is_invokable[][link callable_traits.ref_is_invokable [^is_invokable]]]
[template link_is_invokable_constexpr[][link callable_traits.ref_is_invokable_constexpr [^is_invokable_constexpr]]]
[template link_clear_args[][link callable_traits.ref_clear_args [^clear_args]]]
@@ -185,7 +182,6 @@ This documentation will be most beneficial to readers who posess a basic underst
* [@http://en.cppreference.com/w/cpp/language/overloaded_address taking the address of overloaded functions]
* [@http://en.cppreference.com/w/c/language/variadic C-style variadics], a.k.a. varargs
* [@https://en.wikipedia.org/wiki/X86_calling_conventions calling conventions]
-* [@http://en.cppreference.com/w/cpp/utility/functional/bind std::bind expressions] with [@http://en.cppreference.com/w/cpp/utility/functional/placeholders std::placeholders]
[endsect][/section:prereqs]
@@ -262,12 +258,6 @@ See Also: [link callable_traits.faq.faq_function_types Why not update and extend
[ [Windows] [MinGW GCC \[4.8, ~ 5.2.1)] [[partial_support]] [libstdc++] [-] ]
]
-[template msvc_disabled_functions[]
-
-
-* [link_bind]
-]
-
CallableTraits has not been tested on every platform under the sun. If you find CallableTraits to work with another toolchain, [link callable_traits.contact let us know!]
[section:compatibility_issues Known Issues]
@@ -275,9 +265,6 @@ CallableTraits has not been tested on every platform under the sun. If you find
* [link_is_constexpr] and [link_is_invokable_constexpr] always `std::false_type` on the following platforms:
* MSVC
* GCC < 5
-* [link_bind] trips a static_assert on the following platforms:
- * MSVC
- * GCC < 4.9.2
* [link_min_arity] and [link_max_arity] are equivalent to [link_arity] on the following platforms:
* GCC < 4.9.2
* [link_abominable] types are not compatible with some older compilers. Attempts to create [link_abominable] types using [libname] metafunctions will have no effect on the following platforms:
@@ -373,7 +360,7 @@ There are real reasons to write code like this, but they are few and far between
[*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.
+[*7] (TODO - fill this in)
[*8.] [link_min_arity] can be used to detect the presence of default arguments on a [link_simple_fn_obj]
@@ -678,11 +665,6 @@ In order to avoid significant standardese in the reference sections, we need to
[endsect]
-[section:ref_bind_expression [concept_bind_expression]]
-* The return type of a call to [namespace_scoped]`bind`
-
-[endsect]
-
[section:ref_constexpr_constructible [concept_constexpr_constructible]]
* Any [@http://en.cppreference.com/w/cpp/concept/LiteralType LiteralType] that is also default-constructible
@@ -783,7 +765,6 @@ The [libname] interface is also broken down by trait into individual header file
* [include_header [link_is_invokable]]
* [include_header [link_is_invokable_constexpr]]
* [include_header [link_function_type]]
-* [include_header [link_bind]]
[endsect]
@@ -1169,16 +1150,12 @@ For `add_calling_convention` to work as-intended, you must:
* `T` must be one of the following:
* [link_signature]
* [link_simple_fn_obj]
- * [link_bind_expression]
* When `T` is a [link_signature], then:
* Let `ArgCount` represent the number of arguments in the signature of `T`
* `Index` must be less than `ArgCount` and greater than zero
* Otherwise, when `T` is a [link_simple_fn_obj], then:
* Let `ArgCount` represent the number of arguments in `decltype(&std::decay_t::operator())`
* `Index` must be less than `ArgCount` and greater than zero
-* Otherwise, when `T` is a [link_bind_expression], then:
- * Let `MaxPlaceholder` represent the type of the largest `std::placeholders` object in the bind expression tree
- * `Index` must be less than `std::is_placeholder::value` and greater than zero
[heading Behavior]
* If any constraints are violated, a substitution failure occurs
@@ -1214,7 +1191,6 @@ For `add_calling_convention` to work as-intended, you must:
`T` must be one of the following:
* [link_signature]
* [link_simple_fn_obj]
-* [link_bind_expression]
[heading Behavior]
* When the constraints are violated, a substitution failure occurs
@@ -1224,12 +1200,6 @@ For `add_calling_convention` to work as-intended, you must:
* Otherwise, when `T` is a [link_simple_fn_obj], then:
* Let `Args...` represent the parameter types in the signature of `decltype(&std::decay_t::operator())`
* `args` aliases `std::tuple`
-* Otherwise, when `T` is a [link_bind_expression], then:
- * Let `bind_args...` represent the argument values that were passed to [namespace]`bind` which returned an instance of `T`
- * Let `bind_result` represent the return value of `std::bind(bind_args...)`
- * Let `Args...` represent the "valid argument types" to `bind_result`'s `operator()`
- * Note: the "valid argument types" are implied by the position of the `std::placeholders` objects
- * `args` aliases `std::tuple`
[heading Example]
[import ../example/args.cpp]
@@ -1276,51 +1246,6 @@ For `add_calling_convention` to work as-intended, you must:
[arity]
[endsect]
-[section:ref_bind bind]
-
-[note [namespace_scoped]`bind` [msvc_incompatible]]
-
- namespace ``[lib_namespace]`` {
-
- template
- inline ``[^[link_bind_expression]]`` bind(Ts&&... ts);
-
- }
-
-[namespace_scoped]`bind` is used to parse type information from potentially complex `std::placeholders` expressions. The type information in [namespace_scoped]`bind` cannot legally/portably be extracted from `std::bind`, because `std::bind`'s implementation is opaque.
-
-[heading Constraints]
-* The arguments to [namespace_scoped]`bind` must be legal arguments to `std::bind`, substituting `std::bind` for [namespace_scoped]`bind` in nested sub-expressions where necessary to meet this constraint
-* All nested sub-expressions must be a call to [namespace_scoped]`bind` instead of `std::bind`
-* If a call to [namespace_scoped]`bind` passes an [link_overloaded_fn_obj] instance as its first argument, then:
- * any placeholder objects passed in this call must be re-used somewhere else in the expression tree, bing passed in another call to [namespace_scoped]`bind` where a [link_simple_callable] as its first argument (otherwise, no inference could be made about the parameter type being "place-held")
-
-[heading Behavior]
-* If any constraints are violated, the result is undefined
-* The return type of [namespace_scoped]`bind` can be passed to any of the following:
- * [namespace_scoped][^[link_args]]
- * [namespace_scoped][^[link_arg_at]]
- * [namespace_scoped][^[function_type]]
- * [namespace_scoped][^[result_of]]
-* For convenience, the object returned by [namespace_scoped]`bind` serves as a wrapper around `std::bind`, forwarding from its `operator()` to a private member object constructed from `std::bind` in the original [namespace_scoped]`bind`
-
-[heading Notes]
-* [namespace_scoped]`bind` is the only feature of [libname] with non-constexpr behavior. However, the runtime behavior is only provided for convenience -- [namespace_scoped]`bind` is designed to be a metaprogramming tool, and may be used in unevaluated contexts.
-[heading Example 1]
-[import ../example/bind_1.cpp]
-[bind_1]
-[heading Example 2]
-[import ../example/bind_2.cpp]
-[bind_2]
-
-[heading See Also]
- * [link_args]
- * [link_arg_at]
- * [function_type]
- * [result_of]
-
-[endsect]
-
[section:ref_is_invokable is_invokable]
namespace ``[lib_namespace]`` {
@@ -1497,7 +1422,6 @@ For `add_calling_convention` to work as-intended, you must:
# `T` must be one of the following:
* [link_signature]
* [link_simple_fn_obj]
- * [link_bind_expression]
# Let `std::tuple` represent [namespace_scoped][link_args]``
* `Container` must be a legal template instantiation.
@@ -1559,12 +1483,6 @@ For `add_calling_convention` to work as-intended, you must:
* Let `Args...` represent the parameter types in the signature of `decltype(&std::decay_t::operator())`
* Let `Return` represent the return type of `decltype(&std::decay_t::operator())`
* `function_type` aliases `Return(Args...)`
-*Otherwise, when `T` is a [link_bind_expression], then:
- * Let `std::tuple` represent [namespace_scoped][^[link_args]]``
- * Let `bind_args...` represent the argument values that were passed to [namespace]`bind` which returned an instance of `T`
- * Let `bind_result` represent the return value of `std::bind(bind_args...)`
- * Let `Return` represent `decltype(bind_result(std::declval()...))`
- * `function_type` aliases `Return(Args...)`
[heading Example]
[import ../example/function_type.cpp]
@@ -1851,7 +1769,6 @@ TODO
[result_of]
[endsect]
-[include make_function_example.qbk]
[include interface_example.qbk]
[/*********************************************************************]
diff --git a/doc/html/callable_traits/compatibility.html b/doc/html/callable_traits/compatibility.html
index 0a35e76..09e5601 100644
--- a/doc/html/callable_traits/compatibility.html
+++ b/doc/html/callable_traits/compatibility.html
@@ -495,18 +495,6 @@
-
- bind
- trips a static_assert on the following platforms:
-
- At a glance, there appear to be around 260 search
- results on Stack Overflow concerning the conversion from std::bind
- results to std::function, and around 340 search
- results concerning the conversion of lambdas to std::function.
- There are few good reasons for converting std::bind result
- objects into std::function objects, and fewer still for creating
- std::function objects without explicitly specifying
- the function type. Regardless, here's a make_function
- function, which can...
-
-
-
- Construct an std::function<T>
- where T is not explicitly supplied by the user
-
-
- Construct an std::function<T>
- where T is the implied "signature" of an std::placeholders
- expression
-
-
-
- make_function is rather silly,
- especially since we have no contextual reason for incurring the costs of type
- erasure. Still, it's a lightweight example of the kind of metaprogramming you
- can do with CallableTraits.
-
- Due to limitations in the Microsoft compiler, this example will not compile
- with MSVC. For more information, refer to the Compatibility
- Issues section.
-
#ifndefEXAMPLE_MAKE_FUNCTION_HPP
-#defineEXAMPLE_MAKE_FUNCTION_HPP
-
-#include<functional>
-#include<callable_traits/function_type.hpp>
-#include<callable_traits/bind.hpp>
-
-namespaceexample{
-
- namespacect=callable_traits;
-
- // make_function turns a non-overloaded callable into a type-erased std::function object
- template<typenameT>
- inlinedecltype(auto)make_function(T&&t){
-
- // callable_traits::function_type decays any non-overloaded callable type to
- // a plain function type, which is structured in terms of INVOKE.
-
- usingno_ref=typenamestd::remove_reference<T>::type;
- usingf=ct::function_type<no_ref>;
- usingresult_type=std::function<f>;
- returnresult_type{std::forward<T>(t)};
- }
-
- // this make_function overload turns a bind expression into a type-erased std::function object
- template<typenameT,typenameFirst,typename...Others>
- inlinedecltype(auto)make_function(T&&t,First&&first,Others&&...others){
-
- // callable_traits::bind is essentially a compile-time parser of placeholder
- // expressions, for the purpose of retaining more type information than
- // std::bind normally allows - specifically, callable_traits::bind is used to
- // determine the de-facto signature of the std::bind return type, with special
- // considerations for conversions between reused placeholders and nested
- // placeholder expressions. For the sake of convenience, callable_traits::bind
- // is also a thin forwarding wrapper around std::bind (which is the only true
- // runtime element in CallableTraits).
-
- usingbind_expr=decltype(ct::bind(
- std::forward<T>(t),
- std::forward<First>(first),
- std::forward<Others>(others)...
- ));
-
- usingf=ct::function_type<bind_expr>;
- usingresult_type=std::function<f>;
-
- returnresult_type{std::bind(
- std::forward<T>(t),
- std::forward<First>(first),
- std::forward<Others>(others)...
- )};
- }
-}
-
-#endif//#ifndef EXAMPLE_MAKE_FUNCTION_HPP
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/doc/html/callable_traits/faq.html b/doc/html/callable_traits/faq.html
index c01a56d..0a8e238 100644
--- a/doc/html/callable_traits/faq.html
+++ b/doc/html/callable_traits/faq.html
@@ -164,11 +164,7 @@
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.
+ 7 (TODO - fill this in)
8.min_arity
@@ -257,9 +253,7 @@
a type or a value argument. Even if variable template
support were commonplace among production compilers, function templates would
still have the upper hand in this regard. The same argument applies to alias
- templates and class templates. Since CallableTraits supports
- all value categories and qualifiers, using these function templates really
- couldn't be any easier.
+ templates and class templates.
- Let MaxPlaceholder
- represent the type of the largest std::placeholders
- object in the bind expression tree
-
-
- Index must be less
- than std::is_placeholder<MaxPlaceholder>::value and greater than zero
-
-
-
diff --git a/doc/html/callable_traits/ref_args.html b/doc/html/callable_traits/ref_args.html
index ea3b8e9..e3273ce 100644
--- a/doc/html/callable_traits/ref_args.html
+++ b/doc/html/callable_traits/ref_args.html
@@ -41,7 +41,6 @@
T must be one of the following:
* Signature
* SimpleFunctionObject
- * BindExpression