From 728cfaa456ee8c406e61584d74765b91e893dea4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20M=C3=B6ller?= Date: Thu, 6 Dec 2012 17:45:46 +0100 Subject: [PATCH] Remove CGAL::Overload Equivalent and better functionality is provided by http://www.boost.org/libs//functional/overloaded_function/doc/html/index.html --- .../doc_tex/STL_Extension_ref/main.tex | 1 - .../doc_tex/STL_Extension_ref/overload.tex | 45 ---------------- .../examples/STL_Extension/Overload.cpp | 19 ------- STL_Extension/include/CGAL/Overload.h | 52 ------------------- .../test/STL_Extension/test_Overload.cpp | 49 ----------------- 5 files changed, 166 deletions(-) delete mode 100644 STL_Extension/doc_tex/STL_Extension_ref/overload.tex delete mode 100644 STL_Extension/examples/STL_Extension/Overload.cpp delete mode 100644 STL_Extension/include/CGAL/Overload.h delete mode 100644 STL_Extension/test/STL_Extension/test_Overload.cpp diff --git a/STL_Extension/doc_tex/STL_Extension_ref/main.tex b/STL_Extension/doc_tex/STL_Extension_ref/main.tex index b53da320382..6978aa689e3 100644 --- a/STL_Extension/doc_tex/STL_Extension_ref/main.tex +++ b/STL_Extension/doc_tex/STL_Extension_ref/main.tex @@ -35,7 +35,6 @@ \input{STL_Extension_ref/tuple.tex} \input{STL_Extension_ref/Complexity_tags.tex} \input{STL_Extension_ref/Default.tex} -\input{STL_Extension_ref/overload.tex} %%\cgalColumnLayout diff --git a/STL_Extension/doc_tex/STL_Extension_ref/overload.tex b/STL_Extension/doc_tex/STL_Extension_ref/overload.tex deleted file mode 100644 index 9fe3898bb45..00000000000 --- a/STL_Extension/doc_tex/STL_Extension_ref/overload.tex +++ /dev/null @@ -1,45 +0,0 @@ -\begin{ccRefClass}{Overload} - -\ccInclude{CGAL/Overload.h} - -\ccDefinition - -A class to bundle multiple unary \ccStyle{std::function} or -\ccStyle{boost::function} objects into a single class that overloads -\ccStyle{operator()} for all arguments. - -The return type of the overloaded \ccStyle{operator()} is the -\ccStyle{result_type} of the first argument that was used to create -the overload. The return types of the other function objects should be -convertible to this type. - -This class requires a compiler with support for variadic templates, -rvalues, and tuple. - -The requirements on the argument list \ccStyle{Args} are as follows: -Every element must be of type \ccStyle{std::function}, where T -is implicitly convertible to the nested \ccStyle{result_type} in the -first argument of the list. - -\ccCreation - -\ccConstructor{Overload(Args...&&)} - {creates an Overload for the function objects Args...} - -\ccFunction{template Overload make_overload(Args&&...);} - {Returns an Overload constructed from the arguments.} - -\ccOperations - -\ccMethod{template result_type operator()(T& t);} - {Calls the function that matches the argument \ccStyle{t} best.} - -\ccNestedType{result_type}{The return type of operator()} - -\ccIncludeExampleCode{STL_Extension/Overload.cpp} - -\ccSeeAlso -\ccAnchor{http://wiki.apache.org/stdcxx/C++0xCompilerSupport}{Apache C++11 Compiler support matrix} - - -\end{ccRefClass} diff --git a/STL_Extension/examples/STL_Extension/Overload.cpp b/STL_Extension/examples/STL_Extension/Overload.cpp deleted file mode 100644 index 09a91fbd73a..00000000000 --- a/STL_Extension/examples/STL_Extension/Overload.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include -#include -#include - -// This file requires a compiler with support for the C++0x features auto and lambda -int main() -{ -#if !defined(CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES) && !defined(CGAL_CFG_NO_CPP0X_TUPLE) && !defined(CGAL_CFG_NO_CPP0X_RVALUE_REFERENCE) - auto overload = make_overload( - function([](int) { return 1; }), - function([](char) { return 2; }), - function([](double) { return 3; }) - ); - - std::cout << o(1) << o('a') << " " << o(2.0) << std::endl; -#endif - return 0; -} - diff --git a/STL_Extension/include/CGAL/Overload.h b/STL_Extension/include/CGAL/Overload.h deleted file mode 100644 index 21a443f67aa..00000000000 --- a/STL_Extension/include/CGAL/Overload.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef CGAL_OVERLOAD_H -#define CGAL_OVERLOAD_H - -#include - -#if !defined(CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES) && !defined(CGAL_CFG_NO_CPP0X_TUPLE) && !defined(CGAL_CFG_NO_CPP0X_RVALUE_REFERENCE) - -#include - -namespace CGAL { - -template -struct Overload_helper : public Overload_helper { - typedef typename std::tuple_element::type inner_type; - - typename inner_type::result_type operator()(typename inner_type::argument_type x) { - return std::get(static_cast(this)->t)(x); } - - using Overload_helper::operator(); -}; - -template -struct Overload_helper { - typedef typename std::tuple_element<0 ,T>::type inner_type; - - typename inner_type::result_type operator()(typename inner_type::argument_type x) { - return std::get<0>(static_cast(this)->t)(x); } -}; - -template -struct Overload : public Overload_helper, std::tuple_size >::value, Overload > -{ - typedef std::tuple Tuple_type; - typedef typename std::tuple_element<0, Tuple_type>::type::result_type result_type; - - - Tuple_type t; - - Overload(Args&&... args) : t(std::forward(args)...) {} - explicit Overload(const Tuple_type& t) : t(t) {} - - Overload(Tuple_type&& t) : t(t) {} -}; - -template -Overload make_overload(Args&&... args) { return Overload{ std::forward_as_tuple(args...) }; } - -} // namespace CGAL -#endif // !defined(CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES) && !defined(CGAL_CFG_NO_CPP0X_TUPLE) - -#endif /* CGAL_OVERLOAD_H */ - diff --git a/STL_Extension/test/STL_Extension/test_Overload.cpp b/STL_Extension/test/STL_Extension/test_Overload.cpp deleted file mode 100644 index ae2aac4effd..00000000000 --- a/STL_Extension/test/STL_Extension/test_Overload.cpp +++ /dev/null @@ -1,49 +0,0 @@ -#include - -#if !defined(CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES) && !defined(CGAL_CFG_NO_CPP0X_TUPLE) - -#include -#include -#include -#include -#include -#include - - -void test_overload() { - using namespace CGAL; - using std::function; - - auto t = std::make_tuple(function([](int) { return 1; }), - function([](char) { return 2; }), - function([](double) { return 3; })); - - // manual construction - Overload, function, function > o2(t); - - // basic overload checking - auto o = make_overload(function([](int) { return 1; }), - function([](char) { return 2; }), - function([](double) { return 3; })); - - CGAL_assertion(o(1) == 1); - CGAL_assertion(o('a') == 2); - CGAL_assertion(o(2.0) == 3); - - // check for variants - boost::variant v1 = 1; - boost::variant v2 = 'a'; - boost::variant v3 = 2.0; - - CGAL_assertion(boost::apply_visitor(o, v1) == 1); - CGAL_assertion(boost::apply_visitor(o, v2) == 2); - CGAL_assertion(boost::apply_visitor(o, v3) == 3); -} - -#endif - -int main() { -#if !defined(CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES) && !defined(CGAL_CFG_NO_CPP0X_TUPLE) - test_overload(); -#endif -}