diff --git a/doc/callable_traits.qbk b/doc/callable_traits.qbk index ec1e7a7..96d3391 100644 --- a/doc/callable_traits.qbk +++ b/doc/callable_traits.qbk @@ -94,9 +94,14 @@ Without real-world context, `make_function` may seem rather silly to those who k [endsect] + + [template ct_open_include[] `#include<`[^[header_include_prefix]]] [template ct_close_include[]`.hpp>`] [template include_header[name][ct_open_include][^[name]][ct_close_include][br]] + + + [section:headers Headers] The simplest way to use [library_name] is to include the main header file: @@ -145,7 +150,6 @@ The simplest way to use [library_name] is to include the main header file: [section:ref_add_const_qualifier add_const_qualifier] -[include_header add_const_qualifier] TODO [heading Example] [import ../example/add_const_qualifier.cpp] @@ -153,7 +157,6 @@ TODO [endsect] [section:ref_add_cv_qualifiers add_cv_qualifiers] -[include_header add_cv_qualifiers] TODO [heading Example] [import ../example/add_cv_qualifiers.cpp] @@ -161,29 +164,28 @@ TODO [endsect] [section:ref_add_lvalue_qualifier add_lvalue_qualifier] -[include_header add_lvalue_qualifier] TODO [import ../example/add_lvalue_qualifier.cpp] [add_lvalue_qualifier] [endsect] [section:ref_add_rvalue_qualifier add_rvalue_qualifier] -[include_header add_rvalue_qualifier] TODO +[import ../example/add_rvalue_qualifier.cpp] +[add_rvalue_qualifier] [endsect] [section:ref_add_varargs add_varargs] -[include_header add_varargs] TODO +[import ../example/add_varargs.cpp] +[add_varargs] [endsect] [section:ref_add_volatile_qualifier add_volatile_qualifier] -[include_header add_volatile_qualifier] TODO [endsect] [section:ref_apply_member_pointer apply_member_pointer] -[include_header apply_member_pointer] TODO [heading Example] [import ../example/apply_member_pointer.cpp] @@ -191,7 +193,6 @@ TODO [endsect] [section:ref_apply_return apply_return] -[include_header apply_return] TODO [heading Example] [/import ../example/apply_return.cpp] @@ -199,7 +200,6 @@ TODO [endsect] [section:ref_arg_at arg_at] -[include_header arg_at] TODO [heading Example] [/import ../example/arg_at.cpp] @@ -207,7 +207,6 @@ TODO [endsect] [section:ref_args args] -[include_header args] TODO [heading Example] [import ../example/args.cpp] @@ -215,7 +214,6 @@ TODO [endsect] [section:ref_arity arity] -[include_header arity] TODO [heading Example] [/import ../example/arity.cpp] @@ -223,7 +221,6 @@ TODO [endsect] [section:ref_bind bind] -[include_header bind] TODO [heading Example 1] [import ../example/bind_1.cpp] @@ -234,7 +231,6 @@ TODO [endsect] [section:ref_can_invoke can_invoke] -[include_header can_invoke] TODO [heading Example - Function Object] [import ../example/can_invoke_function_object.cpp] @@ -251,7 +247,6 @@ TODO [endsect] [section:ref_can_invoke_constexpr can_invoke_constexpr] -[include_header can_invoke_constexpr] TODO [heading Example - Function Object] [import ../example/can_invoke_constexpr_function_object.cpp] @@ -265,7 +260,6 @@ TODO [endsect] [section:ref_function_type function_type] -[include_header function_type] TODO [heading Example] [import ../example/function_type.cpp] @@ -273,7 +267,6 @@ TODO [endsect] [section:ref_has_varargs has_varargs] -[include_header has_varargs] TODO [heading Example] [/import ../example/has_varargs.cpp] @@ -281,7 +274,6 @@ TODO [endsect] [section:ref_has_void_return has_void_return] -[include_header has_void_return] TODO [heading Example] [/import ../example/has_void_return.cpp] @@ -289,7 +281,6 @@ TODO [endsect] [section:ref_is_const_qualified is_const_qualified] -[include_header is_const_qualified] TODO [heading Example] [/import ../example/is_const_qualified.cpp] @@ -297,7 +288,6 @@ TODO [endsect] [section:ref_is_constexpr is_constexpr] -[include_header is_constexpr] TODO [heading Example - Function Object] [import ../example/is_constexpr_function_object.cpp] @@ -308,7 +298,6 @@ TODO [endsect] [section:ref_is_lvalue_qualified is_lvalue_qualified] -[include_header is_lvalue_qualified] TODO [heading Example] [/import ../example/is_lvalue_qualified.cpp] @@ -316,7 +305,6 @@ TODO [endsect] [section:ref_is_reference_qualified is_reference_qualified] -[include_header is_reference_qualified] TODO [heading Example] [/import ../example/is_reference_qualified.cpp] @@ -324,7 +312,6 @@ TODO [endsect] [section:ref_is_rvalue_qualified is_rvalue_qualified] -[include_header is_rvalue_qualified] TODO [heading Example] [/import ../example/is_rvalue_qualified.cpp] @@ -332,7 +319,6 @@ TODO [endsect] [section:ref_is_unqualified is_unqualified] -[include_header is_unqualified] TODO [heading Example] [/import ../example/is_unqualified.cpp] @@ -340,7 +326,6 @@ TODO [endsect] [section:ref_is_volatile_qualified is_volatile_qualified] -[include_header is_volatile_qualified] TODO [heading Example] [/import ../example/is_volatile_qualified.cpp] @@ -348,7 +333,6 @@ TODO [endsect] [section:ref_max_arity max_arity] -[include_header max_arity] TODO [heading Example] [/import ../example/max_arity.cpp] @@ -356,7 +340,6 @@ TODO [endsect] [section:ref_min_arity min_arity] -[include_header min_arity] TODO [heading Example] [/import ../example/min_arity.cpp] @@ -364,7 +347,6 @@ TODO [endsect] [section:ref_qualified_function_type qualified_function_type] -[include_header qualified_function_type] TODO [heading Example] [/import ../example/qualified_function_type.cpp] @@ -372,7 +354,6 @@ TODO [endsect] [section:ref_remove_const_qualifier remove_const_qualifier] -[include_header remove_const_qualifier] TODO [heading Example] [/import ../example/remove_const_qualifier.cpp] @@ -380,7 +361,6 @@ TODO [endsect] [section:ref_remove_cv_qualifiers remove_cv_qualifiers] -[include_header remove_cv_qualifiers] TODO [heading Example] [/import ../example/remove_cv_qualifiers.cpp] @@ -388,7 +368,6 @@ TODO [endsect] [section:ref_remove_member_pointer remove_member_pointer] -[include_header remove_member_pointer] TODO [heading Example] [import ../example/remove_member_pointer.cpp] @@ -396,7 +375,6 @@ TODO [endsect] [section:ref_remove_reference_qualifier remove_reference_qualifier] -[include_header remove_reference_qualifier] TODO [heading Example] [/import ../example/remove_reference_qualifier.cpp] @@ -404,7 +382,6 @@ TODO [endsect] [section:ref_remove_varargs remove_varargs] -[include_header remove_varargs] TODO [heading Example] [/import ../example/remove_varargs.cpp] @@ -412,7 +389,6 @@ TODO [endsect] [section:ref_remove_volatile_qualifier remove_volatile_qualifier] -[include_header remove_volatile_qualifier] TODO [heading Example] [/import ../example/remove_volatile_qualifier.cpp] @@ -420,7 +396,7 @@ TODO [endsect] [section:ref_result_of result_of] -[include_header result_of] +TODO [heading Example] [import ../example/result_of.cpp] [result_of] diff --git a/doc/html/callable_traits/ref_add_const_qualifier.html b/doc/html/callable_traits/ref_add_const_qualifier.html index 1df3743..f1d24c7 100644 --- a/doc/html/callable_traits/ref_add_const_qualifier.html +++ b/doc/html/callable_traits/ref_add_const_qualifier.html @@ -27,7 +27,6 @@ add_const_qualifier

- #include<callable_traits/add_const_qualifier.hpp>
TODO

@@ -61,7 +60,7 @@ using test = ct::add_const_qualifier<pmf>; static_assert(std::is_same<test, expect>::value, ""); } { - // add_const_qualifier can also be used to create "abominable" + // add_const_qualifier can also be used with "abominable" // function types. using f = void(); using expect = void() const; diff --git a/doc/html/callable_traits/ref_add_cv_qualifiers.html b/doc/html/callable_traits/ref_add_cv_qualifiers.html index bfe00af..3c22590 100644 --- a/doc/html/callable_traits/ref_add_cv_qualifiers.html +++ b/doc/html/callable_traits/ref_add_cv_qualifiers.html @@ -27,7 +27,6 @@ add_cv_qualifiers

- #include<callable_traits/add_cv_qualifiers.hpp>
TODO

@@ -61,7 +60,7 @@ using test = ct::add_cv_qualifiers<pmf>; static_assert(std::is_same<test, expect>::value, ""); } { - // add_cv_qualifiers can also be used to create "abominable" + // add_cv_qualifiers can also be used with "abominable" // function types. using f = void(); using expect = void() const volatile; diff --git a/doc/html/callable_traits/ref_add_lvalue_qualifier.html b/doc/html/callable_traits/ref_add_lvalue_qualifier.html index aac1ca2..dfd9a70 100644 --- a/doc/html/callable_traits/ref_add_lvalue_qualifier.html +++ b/doc/html/callable_traits/ref_add_lvalue_qualifier.html @@ -27,9 +27,54 @@ add_lvalue_qualifier

- #include<callable_traits/add_lvalue_qualifier.hpp>
TODO

+
#include <type_traits>
+#include <callable_traits/add_lvalue_qualifier.hpp>
+
+namespace ct = callable_traits;
+
+struct foo {};
+
+int main() {
+
+    {
+        using pmf = void(foo::*)();
+        using expect = void(foo::*)() &;
+        using test = ct::add_lvalue_qualifier<pmf>;
+        static_assert(std::is_same<test, expect>::value, "");
+    } {
+        // add_lvalue_qualifier doesn't change anything when
+        // the function type already has an lvalue qualifier.
+        using pmf = void(foo::*)() &;
+        using expect = void(foo::*)() &;
+        using test = ct::add_lvalue_qualifier<pmf>;
+        static_assert(std::is_same<test, expect>::value, "");
+    } {
+        // add_lvalue_qualifier models C++11 reference collapsing
+        // rules, so that adding an lvalue qualifier to an
+        // rvalue-qualified type will force the lvalue.
+        using pmf = void(foo::*)() &&;
+        using expect = void(foo::*)() &;
+        using test = ct::add_lvalue_qualifier<pmf>;
+        static_assert(std::is_same<test, expect>::value, "");
+    } {
+        // add_lvalue_qualifier can also be used to create "abominable"
+        // function types.
+        using f = void();
+        using expect = void() &;
+        using test = ct::add_lvalue_qualifier<f>;
+        static_assert(std::is_same<test, expect>::value, "");
+    } {
+        // add_lvalue_qualifier has no affect on function pointers,
+        // function references, function objects, or member data pointers.
+        using f = int foo::*;
+        using expect = int foo::*;
+        using test = ct::add_lvalue_qualifier<f>;
+        static_assert(std::is_same<test, expect>::value, "");
+    }
+}
+
diff --git a/doc/html/callable_traits/ref_add_rvalue_qualifier.html b/doc/html/callable_traits/ref_add_rvalue_qualifier.html index 6d3f416..ed0b791 100644 --- a/doc/html/callable_traits/ref_add_rvalue_qualifier.html +++ b/doc/html/callable_traits/ref_add_rvalue_qualifier.html @@ -27,9 +27,55 @@ add_rvalue_qualifier

- #include<callable_traits/add_rvalue_qualifier.hpp>
TODO

+
#include <type_traits>
+#include <callable_traits/add_rvalue_qualifier.hpp>
+
+namespace ct = callable_traits;
+
+struct foo {};
+
+int main() {
+
+    {
+        using pmf = void(foo::*)();
+        using expect = void(foo::*)() &&;
+        using test = ct::add_rvalue_qualifier<pmf>;
+        static_assert(std::is_same<test, expect>::value, "");
+    } {
+        // add_rvalue_qualifier doesn't change anything when
+        // the function type already has an rvalue qualifier.
+        using pmf = void(foo::*)() &&;
+        using expect = void(foo::*)() &&;
+        using test = ct::add_rvalue_qualifier<pmf>;
+        static_assert(std::is_same<test, expect>::value, "");
+    } {
+        // add_rvalue_qualifier models C++11 reference collapsing
+        // rules, so that adding an rvalue qualifier to an
+        // lvalue-qualified type will not change anything.
+        using pmf = void(foo::*)() const &;
+        using expect = void(foo::*)() const &;
+        using test = ct::add_rvalue_qualifier<pmf>;
+        static_assert(std::is_same<test, expect>::value, "");
+    } {
+        // add_rvalue_qualifier can also be used with "abominable"
+        // function types.
+        using f = void() const;
+        using expect = void() const &&;
+        using test = ct::add_rvalue_qualifier<f>;
+        static_assert(std::is_same<test, expect>::value, "");
+    } {
+        // add_rvalue_qualifier has no affect on function pointers,
+        // function references, function objects, or member data pointers.
+        auto lambda = []{};
+        using lambda_t = decltype(lambda);
+        using expect = lambda_t;
+        using test = ct::add_rvalue_qualifier<lambda_t>;
+        static_assert(std::is_same<test, expect>::value, "");
+    }
+}
+
diff --git a/doc/html/callable_traits/ref_add_varargs.html b/doc/html/callable_traits/ref_add_varargs.html index 588fed0..e104f37 100644 --- a/doc/html/callable_traits/ref_add_varargs.html +++ b/doc/html/callable_traits/ref_add_varargs.html @@ -27,9 +27,60 @@ add_varargs

- #include<callable_traits/add_varargs.hpp>
TODO

+
#include <type_traits>
+#include <callable_traits/add_varargs.hpp>
+
+namespace ct = callable_traits;
+
+struct foo {};
+
+int main() {
+
+    {
+        using f = void(int);
+        using expect = void(int, ...);
+        using test = ct::add_varargs<f>;
+        static_assert(std::is_same<test, expect>::value, "");
+    } {
+        using fp = void(*)();
+        using expect = void(*)(...);
+        using test = ct::add_varargs<fp>;
+        static_assert(std::is_same<test, expect>::value, "");
+    } {
+        using fr = void(&)(const char*);
+        using expect = void(&)(const char*, ...);
+        using test = ct::add_varargs<fr>;
+        static_assert(std::is_same<test, expect>::value, "");
+    } {
+        using pmf = void(foo::*)() const;
+        using expect = void(foo::*)(...) const;
+        using test = ct::add_varargs<pmf>;
+        static_assert(std::is_same<test, expect>::value, "");
+
+        // add_varargs doesn't change anything when
+        // the type already has varargs.
+        using twice = ct::add_varargs<test>;
+        static_assert(std::is_same<test, twice>::value, "");
+    }
+
+    // add_varargs fails in a SFINAE-friendly manner when
+    // used on a function object or a member data pointer.
+    //
+    // {
+    //     using d = int foo::*;
+    //     using test = ct::add_varargs<d>;
+    // }
+    //
+    // The error message is about as obvious as it can be without
+    // resorting to a SFINAE-unfriendly static_assert (namespaces
+    // omitted for brevity):
+    //
+    //   error: no type named 'type' in 'struct disjunction<
+    //   type_value<invalid_type, false>, add_varargs_error<0> >'
+}
+
diff --git a/doc/html/callable_traits/ref_add_volatile_qualifier.html b/doc/html/callable_traits/ref_add_volatile_qualifier.html index 612b9a8..7a9f0fd 100644 --- a/doc/html/callable_traits/ref_add_volatile_qualifier.html +++ b/doc/html/callable_traits/ref_add_volatile_qualifier.html @@ -27,7 +27,6 @@ add_volatile_qualifier

- #include<callable_traits/add_volatile_qualifier.hpp>
TODO

diff --git a/doc/html/callable_traits/ref_apply_member_pointer.html b/doc/html/callable_traits/ref_apply_member_pointer.html index 07a64c7..ad18179 100644 --- a/doc/html/callable_traits/ref_apply_member_pointer.html +++ b/doc/html/callable_traits/ref_apply_member_pointer.html @@ -27,7 +27,6 @@ apply_member_pointer

- #include<callable_traits/apply_member_pointer.hpp>
TODO

diff --git a/doc/html/callable_traits/ref_apply_return.html b/doc/html/callable_traits/ref_apply_return.html index bef6091..3cfce19 100644 --- a/doc/html/callable_traits/ref_apply_return.html +++ b/doc/html/callable_traits/ref_apply_return.html @@ -27,7 +27,6 @@ apply_return

- #include<callable_traits/apply_return.hpp>
TODO

diff --git a/doc/html/callable_traits/ref_arg_at.html b/doc/html/callable_traits/ref_arg_at.html index 9754235..fa3cac7 100644 --- a/doc/html/callable_traits/ref_arg_at.html +++ b/doc/html/callable_traits/ref_arg_at.html @@ -27,7 +27,6 @@ arg_at

- #include<callable_traits/arg_at.hpp>
TODO

diff --git a/doc/html/callable_traits/ref_args.html b/doc/html/callable_traits/ref_args.html index 6e22017..ac53bd7 100644 --- a/doc/html/callable_traits/ref_args.html +++ b/doc/html/callable_traits/ref_args.html @@ -27,7 +27,6 @@ args

- #include<callable_traits/args.hpp>
TODO

diff --git a/doc/html/callable_traits/ref_arity.html b/doc/html/callable_traits/ref_arity.html index c519166..6ac0f98 100644 --- a/doc/html/callable_traits/ref_arity.html +++ b/doc/html/callable_traits/ref_arity.html @@ -27,7 +27,6 @@ arity

- #include<callable_traits/arity.hpp>
TODO

diff --git a/doc/html/callable_traits/ref_bind.html b/doc/html/callable_traits/ref_bind.html index 771247c..cbd1561 100644 --- a/doc/html/callable_traits/ref_bind.html +++ b/doc/html/callable_traits/ref_bind.html @@ -27,7 +27,6 @@ bind

- #include<callable_traits/bind.hpp>
TODO

diff --git a/doc/html/callable_traits/ref_can_invoke.html b/doc/html/callable_traits/ref_can_invoke.html index befe495..94eeec1 100644 --- a/doc/html/callable_traits/ref_can_invoke.html +++ b/doc/html/callable_traits/ref_can_invoke.html @@ -27,7 +27,6 @@ can_invoke

- #include<callable_traits/can_invoke.hpp>
TODO

diff --git a/doc/html/callable_traits/ref_can_invoke_constexpr.html b/doc/html/callable_traits/ref_can_invoke_constexpr.html index 3d06066..bade120 100644 --- a/doc/html/callable_traits/ref_can_invoke_constexpr.html +++ b/doc/html/callable_traits/ref_can_invoke_constexpr.html @@ -27,7 +27,6 @@ can_invoke_constexpr

- #include<callable_traits/can_invoke_constexpr.hpp>
TODO

diff --git a/doc/html/callable_traits/ref_function_type.html b/doc/html/callable_traits/ref_function_type.html index 77e4abf..2e49b81 100644 --- a/doc/html/callable_traits/ref_function_type.html +++ b/doc/html/callable_traits/ref_function_type.html @@ -27,7 +27,6 @@ function_type

- #include<callable_traits/function_type.hpp>
TODO

diff --git a/doc/html/callable_traits/ref_has_varargs.html b/doc/html/callable_traits/ref_has_varargs.html index 2151faf..fc1407f 100644 --- a/doc/html/callable_traits/ref_has_varargs.html +++ b/doc/html/callable_traits/ref_has_varargs.html @@ -27,7 +27,6 @@ has_varargs

- #include<callable_traits/has_varargs.hpp>
TODO

diff --git a/doc/html/callable_traits/ref_has_void_return.html b/doc/html/callable_traits/ref_has_void_return.html index 76f6621..eb41c6c 100644 --- a/doc/html/callable_traits/ref_has_void_return.html +++ b/doc/html/callable_traits/ref_has_void_return.html @@ -27,7 +27,6 @@ has_void_return

- #include<callable_traits/has_void_return.hpp>
TODO

diff --git a/doc/html/callable_traits/ref_is_const_qualified.html b/doc/html/callable_traits/ref_is_const_qualified.html index 415fa1b..afc86cf 100644 --- a/doc/html/callable_traits/ref_is_const_qualified.html +++ b/doc/html/callable_traits/ref_is_const_qualified.html @@ -27,7 +27,6 @@ is_const_qualified

- #include<callable_traits/is_const_qualified.hpp>
TODO

diff --git a/doc/html/callable_traits/ref_is_constexpr.html b/doc/html/callable_traits/ref_is_constexpr.html index 557f02e..45f6228 100644 --- a/doc/html/callable_traits/ref_is_constexpr.html +++ b/doc/html/callable_traits/ref_is_constexpr.html @@ -27,7 +27,6 @@ is_constexpr

- #include<callable_traits/is_constexpr.hpp>
TODO

diff --git a/doc/html/callable_traits/ref_is_lvalue_qualified.html b/doc/html/callable_traits/ref_is_lvalue_qualified.html index 4a69ddc..cba7500 100644 --- a/doc/html/callable_traits/ref_is_lvalue_qualified.html +++ b/doc/html/callable_traits/ref_is_lvalue_qualified.html @@ -27,7 +27,6 @@ is_lvalue_qualified

- #include<callable_traits/is_lvalue_qualified.hpp>
TODO

diff --git a/doc/html/callable_traits/ref_is_reference_qualified.html b/doc/html/callable_traits/ref_is_reference_qualified.html index 91519d0..0fa0983 100644 --- a/doc/html/callable_traits/ref_is_reference_qualified.html +++ b/doc/html/callable_traits/ref_is_reference_qualified.html @@ -27,7 +27,6 @@ is_reference_qualified

- #include<callable_traits/is_reference_qualified.hpp>
TODO

diff --git a/doc/html/callable_traits/ref_is_rvalue_qualified.html b/doc/html/callable_traits/ref_is_rvalue_qualified.html index 64cd7aa..1435a8f 100644 --- a/doc/html/callable_traits/ref_is_rvalue_qualified.html +++ b/doc/html/callable_traits/ref_is_rvalue_qualified.html @@ -27,7 +27,6 @@ is_rvalue_qualified

- #include<callable_traits/is_rvalue_qualified.hpp>
TODO

diff --git a/doc/html/callable_traits/ref_is_unqualified.html b/doc/html/callable_traits/ref_is_unqualified.html index 63c7eaf..1b43668 100644 --- a/doc/html/callable_traits/ref_is_unqualified.html +++ b/doc/html/callable_traits/ref_is_unqualified.html @@ -27,7 +27,6 @@ is_unqualified

- #include<callable_traits/is_unqualified.hpp>
TODO

diff --git a/doc/html/callable_traits/ref_is_volatile_qualified.html b/doc/html/callable_traits/ref_is_volatile_qualified.html index 7a3e77a..b65e8ce 100644 --- a/doc/html/callable_traits/ref_is_volatile_qualified.html +++ b/doc/html/callable_traits/ref_is_volatile_qualified.html @@ -27,7 +27,6 @@ is_volatile_qualified

- #include<callable_traits/is_volatile_qualified.hpp>
TODO

diff --git a/doc/html/callable_traits/ref_max_arity.html b/doc/html/callable_traits/ref_max_arity.html index 280b39a..37b423c 100644 --- a/doc/html/callable_traits/ref_max_arity.html +++ b/doc/html/callable_traits/ref_max_arity.html @@ -27,7 +27,6 @@ max_arity

- #include<callable_traits/max_arity.hpp>
TODO

diff --git a/doc/html/callable_traits/ref_min_arity.html b/doc/html/callable_traits/ref_min_arity.html index f0f8f69..ad6d0b2 100644 --- a/doc/html/callable_traits/ref_min_arity.html +++ b/doc/html/callable_traits/ref_min_arity.html @@ -27,7 +27,6 @@ min_arity

- #include<callable_traits/min_arity.hpp>
TODO

diff --git a/doc/html/callable_traits/ref_qualified_function_type.html b/doc/html/callable_traits/ref_qualified_function_type.html index c8f0a4f..bb18ef6 100644 --- a/doc/html/callable_traits/ref_qualified_function_type.html +++ b/doc/html/callable_traits/ref_qualified_function_type.html @@ -27,7 +27,6 @@ qualified_function_type

- #include<callable_traits/qualified_function_type.hpp>
TODO

diff --git a/doc/html/callable_traits/ref_remove_const_qualifier.html b/doc/html/callable_traits/ref_remove_const_qualifier.html index b0e3459..e7ce1bc 100644 --- a/doc/html/callable_traits/ref_remove_const_qualifier.html +++ b/doc/html/callable_traits/ref_remove_const_qualifier.html @@ -27,7 +27,6 @@ remove_const_qualifier

- #include<callable_traits/remove_const_qualifier.hpp>
TODO

diff --git a/doc/html/callable_traits/ref_remove_cv_qualifiers.html b/doc/html/callable_traits/ref_remove_cv_qualifiers.html index fae36c4..d716927 100644 --- a/doc/html/callable_traits/ref_remove_cv_qualifiers.html +++ b/doc/html/callable_traits/ref_remove_cv_qualifiers.html @@ -27,7 +27,6 @@ remove_cv_qualifiers

- #include<callable_traits/remove_cv_qualifiers.hpp>
TODO

diff --git a/doc/html/callable_traits/ref_remove_member_pointer.html b/doc/html/callable_traits/ref_remove_member_pointer.html index 57e77ab..4f2979f 100644 --- a/doc/html/callable_traits/ref_remove_member_pointer.html +++ b/doc/html/callable_traits/ref_remove_member_pointer.html @@ -27,7 +27,6 @@ remove_member_pointer

- #include<callable_traits/remove_member_pointer.hpp>
TODO

diff --git a/doc/html/callable_traits/ref_remove_reference_qualifier.html b/doc/html/callable_traits/ref_remove_reference_qualifier.html index 0b803e9..3778e68 100644 --- a/doc/html/callable_traits/ref_remove_reference_qualifier.html +++ b/doc/html/callable_traits/ref_remove_reference_qualifier.html @@ -27,7 +27,6 @@ remove_reference_qualifier

- #include<callable_traits/remove_reference_qualifier.hpp>
TODO

diff --git a/doc/html/callable_traits/ref_remove_varargs.html b/doc/html/callable_traits/ref_remove_varargs.html index 612036e..f0a02b0 100644 --- a/doc/html/callable_traits/ref_remove_varargs.html +++ b/doc/html/callable_traits/ref_remove_varargs.html @@ -27,7 +27,6 @@ remove_varargs

- #include<callable_traits/remove_varargs.hpp>
TODO

diff --git a/doc/html/callable_traits/ref_remove_volatile_qualifier.html b/doc/html/callable_traits/ref_remove_volatile_qualifier.html index 1d3d4b4..3e3d7db 100644 --- a/doc/html/callable_traits/ref_remove_volatile_qualifier.html +++ b/doc/html/callable_traits/ref_remove_volatile_qualifier.html @@ -27,7 +27,6 @@ remove_volatile_qualifier

- #include<callable_traits/remove_volatile_qualifier.hpp>
TODO

diff --git a/doc/html/callable_traits/ref_result_of.html b/doc/html/callable_traits/ref_result_of.html index 2cfe24e..64dd91d 100644 --- a/doc/html/callable_traits/ref_result_of.html +++ b/doc/html/callable_traits/ref_result_of.html @@ -26,7 +26,7 @@ result_of

- #include<callable_traits/result_of.hpp>
+ TODO

diff --git a/example/add_const_qualifier.cpp b/example/add_const_qualifier.cpp index 9e0a531..24f5eac 100644 --- a/example/add_const_qualifier.cpp +++ b/example/add_const_qualifier.cpp @@ -32,7 +32,7 @@ int main() { using test = ct::add_const_qualifier; static_assert(std::is_same::value, ""); } { - // add_const_qualifier can also be used to create "abominable" + // add_const_qualifier can also be used with "abominable" // function types. using f = void(); using expect = void() const; diff --git a/example/add_cv_qualifiers.cpp b/example/add_cv_qualifiers.cpp index 7eded16..05eac45 100644 --- a/example/add_cv_qualifiers.cpp +++ b/example/add_cv_qualifiers.cpp @@ -32,7 +32,7 @@ int main() { using test = ct::add_cv_qualifiers; static_assert(std::is_same::value, ""); } { - // add_cv_qualifiers can also be used to create "abominable" + // add_cv_qualifiers can also be used with "abominable" // function types. using f = void(); using expect = void() const volatile; diff --git a/example/add_rvalue_qualifier.cpp b/example/add_rvalue_qualifier.cpp new file mode 100644 index 0000000..4ca622f --- /dev/null +++ b/example/add_rvalue_qualifier.cpp @@ -0,0 +1,55 @@ +/*<- +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) +->*/ + +//[ add_rvalue_qualifier +#include +#include + +namespace ct = callable_traits; + +struct foo {}; + +int main() { + + { + using pmf = void(foo::*)(); + using expect = void(foo::*)() &&; + using test = ct::add_rvalue_qualifier; + static_assert(std::is_same::value, ""); + } { + // add_rvalue_qualifier doesn't change anything when + // the function type already has an rvalue qualifier. + using pmf = void(foo::*)() &&; + using expect = void(foo::*)() &&; + using test = ct::add_rvalue_qualifier; + static_assert(std::is_same::value, ""); + } { + // add_rvalue_qualifier models C++11 reference collapsing + // rules, so that adding an rvalue qualifier to an + // lvalue-qualified type will not change anything. + using pmf = void(foo::*)() const &; + using expect = void(foo::*)() const &; + using test = ct::add_rvalue_qualifier; + static_assert(std::is_same::value, ""); + } { + // add_rvalue_qualifier can also be used with "abominable" + // function types. + using f = void() const; + using expect = void() const &&; + using test = ct::add_rvalue_qualifier; + static_assert(std::is_same::value, ""); + } { + // add_rvalue_qualifier has no affect on function pointers, + // function references, function objects, or member data pointers. + auto lambda = []{}; + using lambda_t = decltype(lambda); + using expect = lambda_t; + using test = ct::add_rvalue_qualifier; + static_assert(std::is_same::value, ""); + } +} +//] + diff --git a/example/add_varargs.cpp b/example/add_varargs.cpp new file mode 100644 index 0000000..155bcd8 --- /dev/null +++ b/example/add_varargs.cpp @@ -0,0 +1,59 @@ +/*<- +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) +->*/ + +//[ add_varargs +#include +#include + +namespace ct = callable_traits; + +struct foo {}; + +int main() { + + { + using f = void(int); + using expect = void(int, ...); + using test = ct::add_varargs; + static_assert(std::is_same::value, ""); + } { + using fp = void(*)(); + using expect = void(*)(...); + using test = ct::add_varargs; + static_assert(std::is_same::value, ""); + } { + using fr = void(&)(const char*); + using expect = void(&)(const char*, ...); + using test = ct::add_varargs; + static_assert(std::is_same::value, ""); + } { + using pmf = void(foo::*)() const; + using expect = void(foo::*)(...) const; + using test = ct::add_varargs; + static_assert(std::is_same::value, ""); + + // add_varargs doesn't change anything when + // the type already has varargs. + using twice = ct::add_varargs; + static_assert(std::is_same::value, ""); + } + + // add_varargs fails in a SFINAE-friendly manner when + // used on a function object or a member data pointer. + // + // { + // using d = int foo::*; + // using test = ct::add_varargs; + // } + // + // The error message is about as obvious as it can be without + // resorting to a SFINAE-unfriendly static_assert (namespaces + // omitted for brevity): + // + // error: no type named 'type' in 'struct disjunction< + // type_value, add_varargs_error<0> >' +} +//] diff --git a/include/callable_traits/detail/set_function_qualifiers.hpp b/include/callable_traits/detail/set_function_qualifiers.hpp index c74cffa..42b52c4 100644 --- a/include/callable_traits/detail/set_function_qualifiers.hpp +++ b/include/callable_traits/detail/set_function_qualifiers.hpp @@ -82,4 +82,4 @@ namespace callable_traits { } } -#endif //CALLABLE_TRAITS_SET_FUNCTION_QUALIFIERS \ No newline at end of file +#endif //CALLABLE_TRAITS_DETAIL_SET_FUNCTION_QUALIFIERS_HPP diff --git a/qtcreator/main/main.cpp b/qtcreator/main/main.cpp index d8a6f83..bb1db9e 100644 --- a/qtcreator/main/main.cpp +++ b/qtcreator/main/main.cpp @@ -4,9 +4,9 @@ Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http ://boost.org/LICENSE_1_0.txt) ->*/ -//[ add_lvalue_qualifier +//[ add_varargs #include -#include +#include namespace ct = callable_traits; @@ -15,39 +15,45 @@ struct foo {}; int main() { { - using pmf = void(foo::*)(); - using expect = void(foo::*)() &; - using test = ct::add_lvalue_qualifier; + using f = void(int); + using expect = void(int, ...); + using test = ct::add_varargs; static_assert(std::is_same::value, ""); } { - // add_lvalue_qualifier doesn't change anything when - // the function type already has an lvalue qualifier. - using pmf = void(foo::*)() &; - using expect = void(foo::*)() &; - using test = ct::add_lvalue_qualifier; + using fp = void(*)(int); + using expect = void(*)(int, ...); + using test = ct::add_varargs; static_assert(std::is_same::value, ""); } { - // add_lvalue_qualifier models C++11 reference collapsing - // rules, so that adding an lvalue qualifier to an - // rvalue-qualified type will force the lvalue. - using pmf = void(foo::*)() &&; - using expect = void(foo::*)() &; - using test = ct::add_lvalue_qualifier; + using fr = void(&)(int); + using expect = void(&)(int, ...); + using test = ct::add_varargs; static_assert(std::is_same::value, ""); } { - // add_lvalue_qualifier can also be used to create "abominable" - // function types. - using f = void(); - using expect = void() &; - using test = ct::add_lvalue_qualifier; - static_assert(std::is_same::value, ""); - } { - // add_lvalue_qualifier has no affect on function pointers, - // function references, function objects, or member data pointers. - using f = int foo::*; - using expect = int foo::*; - using test = ct::add_lvalue_qualifier; + using pmf = void(foo::*)(int) const; + using expect = void(foo::*)(int, ...) const; + using test = ct::add_varargs; static_assert(std::is_same::value, ""); + + // add_varargs doesn't change anything when + // the type already has varargs. + using twice = ct::add_varargs; + static_assert(std::is_same::value, ""); } + + // add_varargs fails in a SFINAE-friendly manner when + // used on a function object or a member data pointer. + // + // { + // using d = int foo::*; + // using test = ct::add_varargs; + // } + // + // The error message is about as obvious as it can be without + // resorting to a SFINAE-unfriendly static_assert (namespaces + // omitted for brevity): + // + // error: no type named 'type' in 'struct disjunction< + // type_value, add_varargs_error<0> >' } //]