DriveHQ Start Menu
Cloud Drive Mapping
Folder Sync
Cloud Backup
True Drop Box
FTP/SFTP Hosting
Group Account
DriveHQ Start Menu
Online File Server
My Storage
|
Manage Shares
|
Publishes
|
Drop Boxes
|
Group Account
WebDAV Drive Mapping
Cloud Drive Home
|
WebDAV Guide
|
Drive Mapping Tool
|
Drive Mapping URL
Complete Data Backup
Backup Guide
|
Online Backup Tool
|
Cloud-to-Cloud Backup
FTP, Email & Web Service
FTP Home
|
FTP Hosting FAQ
|
Email Hosting
|
EmailManager
|
Web Hosting
Help & Resources
About
|
Enterprise Service
|
Partnership
|
Comparisons
|
Support
Quick Links
Security and Privacy
Download Software
Service Manual
Use Cases
Group Account
Online Help
Blog
Contact
Cloud Surveillance
Sign Up
Login
Features
Business Features
Online File Server
FTP Hosting
Cloud Drive Mapping
Cloud File Backup
Email Backup & Hosting
Cloud File Sharing
Folder Synchronization
Group Management
True Drop Box
Full-text Search
AD Integration/SSO
Mobile Access
IP Camera & DVR Solution
More...
Personal Features
Personal Cloud Drive
Backup All Devices
Mobile APPs
Personal Web Hosting
Sub-Account (for Kids)
Home/PC/Kids Monitoring
More...
Software
DriveHQ Drive Mapping Tool
DriveHQ FileManager
DriveHQ Online Backup
DriveHQ Mobile Apps
Pricing
Business Plans & Pricing
Personal Plans & Pricing
Price Comparison with Others
Feature Comparison with Others
Install Mobile App
Sign up
Creating account...
Invalid character in username! Only 0-9, a-z, A-Z, _, -, . allowed.
Username is required!
Invalid email address!
E-mail is required!
Password is required!
Password is invalid!
Password and confirmation do not match.
Confirm password is required!
I accept
Membership Agreement
Please read the Membership Agreement and check "I accept"!
Free Quick Sign-up
Sign-up Page
Log in
Signing in...
Username or e-mail address is required!
Password is required!
Keep me logged in
Quick Login
Forgot Password
Up
Upload
Download
Share
Publish
New Folder
New File
Copy
Cut
Delete
Paste
Rate
Upgrade
Rotate
Effect
Edit
Slide
History
// Boost Lambda Library ret.hpp ----------------------------------------- // Copyright (C) 1999, 2000 Jaakko J�rvi (jaakko.jarvi@cs.utu.fi) // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // For more information, see www.boost.org #ifndef BOOST_LAMBDA_RET_HPP #define BOOST_LAMBDA_RET_HPP namespace boost { namespace lambda { // TODO: // Add specializations for function references for ret, protect and unlambda // e.g void foo(); unlambda(foo); fails, as it would add a const qualifier // for a function type. // on the other hand unlambda(*foo) does work // -- ret ------------------------- // the explicit return type template // TODO: It'd be nice to make ret a nop for other than lambda functors // but causes an ambiguiyty with gcc (not with KCC), check what is the // right interpretation. // // ret for others than lambda functors has no effect // template
// inline const T& ret(const T& t) { return t; } template
inline const lambda_functor< lambda_functor_base< explicit_return_type_action
, tuple
> > > ret(const lambda_functor
& a1) { return lambda_functor_base< explicit_return_type_action
, tuple
> > (tuple
>(a1)); } // protect ------------------ // protecting others than lambda functors has no effect template
inline const T& protect(const T& t) { return t; } template
inline const lambda_functor< lambda_functor_base< protect_action, tuple
> > > protect(const lambda_functor
& a1) { return lambda_functor_base< protect_action, tuple
> > (tuple
>(a1)); } // ------------------------------------------------------------------- // Hides the lambda functorness of a lambda functor. // After this, the functor is immune to argument substitution, etc. // This can be used, e.g. to make it safe to pass lambda functors as // arguments to functions, which might use them as target functions // note, unlambda and protect are different things. Protect hides the lambda // functor for one application, unlambda for good. template
class non_lambda_functor { LambdaFunctor lf; public: // This functor defines the result_type typedef. // The result type must be deducible without knowing the arguments template
struct sig { typedef typename LambdaFunctor::inherited:: template sig
::type type; }; explicit non_lambda_functor(const LambdaFunctor& a) : lf(a) {} typename LambdaFunctor::nullary_return_type operator()() const { return lf.template call
(cnull_type(), cnull_type(), cnull_type(), cnull_type()); } template
typename sig
>::type operator()(A& a) const { return lf.template call
>::type >(a, cnull_type(), cnull_type(), cnull_type()); } template
typename sig
>::type operator()(A& a, B& b) const { return lf.template call
>::type >(a, b, cnull_type(), cnull_type()); } template
typename sig
>::type operator()(A& a, B& b, C& c) const { return lf.template call
>::type>(a, b, c, cnull_type()); } }; template
inline const Arg& unlambda(const Arg& a) { return a; } template
inline const non_lambda_functor
> unlambda(const lambda_functor
& a) { return non_lambda_functor
>(a); } // Due to a language restriction, lambda functors cannot be made to // accept non-const rvalue arguments. Usually iterators do not return // temporaries, but sometimes they do. That's why a workaround is provided. // Note, that this potentially breaks const correctness, so be careful! // any lambda functor can be turned into a const_incorrect_lambda_functor // The operator() takes arguments as consts and then casts constness // away. So this breaks const correctness!!! but is a necessary workaround // in some cases due to language limitations. // Note, that this is not a lambda_functor anymore, so it can not be used // as a sub lambda expression. template
struct const_incorrect_lambda_functor { LambdaFunctor lf; public: explicit const_incorrect_lambda_functor(const LambdaFunctor& a) : lf(a) {} template
struct sig { typedef typename LambdaFunctor::inherited::template sig
::type type; }; // The nullary case is not needed (no arguments, no parameter type problems) template
typename sig
>::type operator()(const A& a) const { return lf.template call
>::type >(const_cast
(a), cnull_type(), cnull_type(), cnull_type()); } template
typename sig
>::type operator()(const A& a, const B& b) const { return lf.template call
>::type >(const_cast
(a), const_cast
(b), cnull_type(), cnull_type()); } template
typename sig
>::type operator()(const A& a, const B& b, const C& c) const { return lf.template call
>::type>(const_cast
(a), const_cast
(b), const_cast
(c), cnull_type()); } }; // ------------------------------------------------------------------------ // any lambda functor can be turned into a const_parameter_lambda_functor // The operator() takes arguments as const. // This is useful if lambda functors are called with non-const rvalues. // Note, that this is not a lambda_functor anymore, so it can not be used // as a sub lambda expression. template
struct const_parameter_lambda_functor { LambdaFunctor lf; public: explicit const_parameter_lambda_functor(const LambdaFunctor& a) : lf(a) {} template
struct sig { typedef typename LambdaFunctor::inherited::template sig
::type type; }; // The nullary case is not needed: no arguments, no constness problems. template
typename sig
>::type operator()(const A& a) const { return lf.template call
>::type >(a, cnull_type(), cnull_type(), cnull_type()); } template
typename sig
>::type operator()(const A& a, const B& b) const { return lf.template call
>::type >(a, b, cnull_type(), cnull_type()); } template
typename sig
>::type operator()(const A& a, const B& b, const C& c) const { return lf.template call
>::type>(a, b, c, cnull_type()); } }; template
inline const const_incorrect_lambda_functor
> break_const(const lambda_functor
& lf) { return const_incorrect_lambda_functor
>(lf); } template
inline const const_parameter_lambda_functor
> const_parameters(const lambda_functor
& lf) { return const_parameter_lambda_functor
>(lf); } // make void ------------------------------------------------ // make_void( x ) turns a lambda functor x with some return type y into // another lambda functor, which has a void return type // when called, the original return type is discarded // we use this action. The action class will be called, which means that // the wrapped lambda functor is evaluated, but we just don't do anything // with the result. struct voidifier_action { template
static void apply(A&) {} }; template
struct return_type_N
{ typedef void type; }; template
inline const lambda_functor< lambda_functor_base< action<1, voidifier_action>, tuple
> > > make_void(const lambda_functor
& a1) { return lambda_functor_base< action<1, voidifier_action>, tuple
> > (tuple
> (a1)); } // for non-lambda functors, make_void does nothing // (the argument gets evaluated immediately) template
inline const lambda_functor< lambda_functor_base
> make_void(const Arg1& a1) { return lambda_functor_base
(); } // std_functor ----------------------------------------------------- // The STL uses the result_type typedef as the convention to let binders know // the return type of a function object. // LL uses the sig template. // To let LL know that the function object has the result_type typedef // defined, it can be wrapped with the std_functor function. // Just inherit form the template parameter (the standard functor), // and provide a sig template. So we have a class which is still the // same functor + the sig template. template
struct result_type_to_sig : public T { template
struct sig { typedef typename T::result_type type; }; result_type_to_sig(const T& t) : T(t) {} }; template
inline result_type_to_sig
std_functor(const F& f) { return f; } } // namespace lambda } // namespace boost #endif
ret.hpp
Page URL
File URL
Prev
18/20
Next
Download
( 10 KB )
Note: The DriveHQ service banners will NOT be displayed if the file owner is a paid member.
Comments
Total ratings:
0
Average rating:
Not Rated
Would you like to comment?
Join DriveHQ
for a free account, or
Logon
if you are already a member.