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 -- control_structures_impl.hpp --------------------- // Copyright (C) 1999, 2000 Jaakko J�rvi (jaakko.jarvi@cs.utu.fi) // Copyright (C) 2000 Gary Powell (powellg@amazon.com) // // 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 // -------------------------------------------------------------------------- #if !defined(BOOST_LAMBDA_CONTROL_CONSTRUCTS_HPP) #define BOOST_LAMBDA_CONTROL_CONSTRUCTS_HPP namespace boost { namespace lambda { // -- void return control actions ---------------------- class forloop_action {}; class forloop_no_body_action {}; class ifthen_action {}; class ifthenelse_action {}; class whileloop_action {}; class whileloop_no_body_action {}; class dowhileloop_action {}; class dowhileloop_no_body_action {}; // -- nonvoid return control actions ---------------------- class ifthenelsereturn_action {}; // For loop template
inline const lambda_functor< lambda_functor_base< forloop_action, tuple
, lambda_functor
, lambda_functor
, lambda_functor
> > > for_loop(const lambda_functor
& a1, const lambda_functor
& a2, const lambda_functor
& a3, const lambda_functor
& a4) { return lambda_functor_base< forloop_action, tuple
, lambda_functor
, lambda_functor
, lambda_functor
> > ( tuple
, lambda_functor
, lambda_functor
, lambda_functor
>(a1, a2, a3, a4) ); } // No body case. template
inline const lambda_functor< lambda_functor_base< forloop_no_body_action, tuple
, lambda_functor
, lambda_functor
> > > for_loop(const lambda_functor
& a1, const lambda_functor
& a2, const lambda_functor
& a3) { return lambda_functor_base< forloop_no_body_action, tuple
, lambda_functor
, lambda_functor
> > ( tuple
, lambda_functor
, lambda_functor
>(a1, a2, a3) ); } // While loop template
inline const lambda_functor< lambda_functor_base< whileloop_action, tuple
, lambda_functor
> > > while_loop(const lambda_functor
& a1, const lambda_functor
& a2) { return lambda_functor_base< whileloop_action, tuple
, lambda_functor
> > ( tuple
, lambda_functor
>(a1, a2)); } // No body case. template
inline const lambda_functor< lambda_functor_base< whileloop_no_body_action, tuple
> > > while_loop(const lambda_functor
& a1) { return lambda_functor_base< whileloop_no_body_action, tuple
> > ( tuple
>(a1) ); } // Do While loop template
inline const lambda_functor< lambda_functor_base< dowhileloop_action, tuple
, lambda_functor
> > > do_while_loop(const lambda_functor
& a1, const lambda_functor
& a2) { return lambda_functor_base< dowhileloop_action, tuple
, lambda_functor
> > ( tuple
, lambda_functor
>(a1, a2)); } // No body case. template
inline const lambda_functor< lambda_functor_base< dowhileloop_no_body_action, tuple
> > > do_while_loop(const lambda_functor
& a1) { return lambda_functor_base< dowhileloop_no_body_action, tuple
> > ( tuple
>(a1)); } // If Then template
inline const lambda_functor< lambda_functor_base< ifthen_action, tuple
, lambda_functor
> > > if_then(const lambda_functor
& a1, const lambda_functor
& a2) { return lambda_functor_base< ifthen_action, tuple
, lambda_functor
> > ( tuple
, lambda_functor
>(a1, a2) ); } // If then else template
inline const lambda_functor< lambda_functor_base< ifthenelse_action, tuple
, lambda_functor
, lambda_functor
> > > if_then_else(const lambda_functor
& a1, const lambda_functor
& a2, const lambda_functor
& a3) { return lambda_functor_base< ifthenelse_action, tuple
, lambda_functor
, lambda_functor
> > (tuple
, lambda_functor
, lambda_functor
> (a1, a2, a3) ); } // Our version of operator?:() template
inline const lambda_functor< lambda_functor_base< other_action
, tuple
, typename const_copy_argument
::type, typename const_copy_argument
::type> > > if_then_else_return(const lambda_functor
& a1, const Arg2 & a2, const Arg3 & a3) { return lambda_functor_base< other_action
, tuple
, typename const_copy_argument
::type, typename const_copy_argument
::type> > ( tuple
, typename const_copy_argument
::type, typename const_copy_argument
::type> (a1, a2, a3) ); } namespace detail { // return type specialization for conditional expression begins ----------- // start reading below and move upwards // PHASE 6:1 // check if A is conbertible to B and B to A template
struct return_type_2_ifthenelsereturn; // if A can be converted to B and vice versa -> ambiguous template
struct return_type_2_ifthenelsereturn
{ typedef detail::return_type_deduction_failure
type; // ambiguous type in conditional expression }; // if A can be converted to B and vice versa and are of same type template
struct return_type_2_ifthenelsereturn
{ typedef A type; }; // A can be converted to B template
struct return_type_2_ifthenelsereturn
{ typedef B type; }; // B can be converted to A template
struct return_type_2_ifthenelsereturn
{ typedef A type; }; // neither can be converted. Then we drop the potential references, and // try again template
struct return_type_2_ifthenelsereturn<1, false, false, false, A, B> { // it is safe to add const, since the result will be an rvalue and thus // const anyway. The const are needed eg. if the types // are 'const int*' and 'void *'. The remaining type should be 'const void*' typedef const typename boost::remove_reference
::type plainA; typedef const typename boost::remove_reference
::type plainB; // TODO: Add support for volatile ? typedef typename return_type_2_ifthenelsereturn< 2, boost::is_convertible
::value, boost::is_convertible
::value, boost::is_same
::value, plainA, plainB>::type type; }; // PHASE 6:2 template
struct return_type_2_ifthenelsereturn<2, false, false, false, A, B> { typedef detail::return_type_deduction_failure
type; // types_do_not_match_in_conditional_expression }; // PHASE 5: now we know that types are not arithmetic. template
struct non_numeric_types { typedef typename return_type_2_ifthenelsereturn< 1, // phase 1 is_convertible
::value, is_convertible
::value, is_same
::value, A, B>::type type; }; // PHASE 4 : // the base case covers arithmetic types with differing promote codes // use the type deduction of arithmetic_actions template
struct arithmetic_or_not { typedef typename return_type_2
, A, B>::type type; // plus_action is just a random pick, has to be a concrete instance }; // this case covers the case of artihmetic types with the same promote codes. // non numeric deduction is used since e.g. integral promotion is not // performed with operator ?: template
struct arithmetic_or_not
{ typedef typename non_numeric_types
::type type; }; // if either A or B has promote code -1 it is not an arithmetic type template
struct arithmetic_or_not <-1, -1, A, B> { typedef typename non_numeric_types
::type type; }; template
struct arithmetic_or_not <-1, CodeB, A, B> { typedef typename non_numeric_types
::type type; }; template
struct arithmetic_or_not
{ typedef typename non_numeric_types
::type type; }; // PHASE 3 : Are the types same? // No, check if they are arithmetic or not template
struct same_or_not { typedef typename detail::remove_reference_and_cv
::type plainA; typedef typename detail::remove_reference_and_cv
::type plainB; typedef typename arithmetic_or_not< detail::promote_code
::value, detail::promote_code
::value, A, B>::type type; }; // Yes, clear. template
struct same_or_not
{ typedef A type; }; } // detail // PHASE 2 : Perform first the potential array_to_pointer conversion template
struct return_type_2
, A, B> { typedef typename detail::array_to_pointer
::type A1; typedef typename detail::array_to_pointer
::type B1; typedef typename boost::add_const
::type>::type type; }; // PHASE 1 : Deduction is based on the second and third operand // return type specialization for conditional expression ends ----------- // Control loop lambda_functor_base specializations. // Specialization for for_loop. template
class lambda_functor_base
{ public: Args args; template
struct sig { typedef void type; }; public: explicit lambda_functor_base(const Args& a) : args(a) {} template
RET call(CALL_FORMAL_ARGS) const { for(detail::select(boost::tuples::get<0>(args), CALL_ACTUAL_ARGS); detail::select(boost::tuples::get<1>(args), CALL_ACTUAL_ARGS); detail::select(boost::tuples::get<2>(args), CALL_ACTUAL_ARGS)) detail::select(boost::tuples::get<3>(args), CALL_ACTUAL_ARGS); } }; // No body case template
class lambda_functor_base
{ public: Args args; template
struct sig { typedef void type; }; public: explicit lambda_functor_base(const Args& a) : args(a) {} template
RET call(CALL_FORMAL_ARGS) const { for(detail::select(boost::tuples::get<0>(args), CALL_ACTUAL_ARGS); detail::select(boost::tuples::get<1>(args), CALL_ACTUAL_ARGS); detail::select(boost::tuples::get<2>(args), CALL_ACTUAL_ARGS)) {} } }; // Specialization for while_loop. template
class lambda_functor_base
{ public: Args args; template
struct sig { typedef void type; }; public: explicit lambda_functor_base(const Args& a) : args(a) {} template
RET call(CALL_FORMAL_ARGS) const { while(detail::select(boost::tuples::get<0>(args), CALL_ACTUAL_ARGS)) detail::select(boost::tuples::get<1>(args), CALL_ACTUAL_ARGS); } }; // No body case template
class lambda_functor_base
{ public: Args args; template
struct sig { typedef void type; }; public: explicit lambda_functor_base(const Args& a) : args(a) {} template
RET call(CALL_FORMAL_ARGS) const { while(detail::select(boost::tuples::get<0>(args), CALL_ACTUAL_ARGS)) {} } }; // Specialization for do_while_loop. // Note that the first argument is the condition. template
class lambda_functor_base
{ public: Args args; template
struct sig { typedef void type; }; public: explicit lambda_functor_base(const Args& a) : args(a) {} template
RET call(CALL_FORMAL_ARGS) const { do { detail::select(boost::tuples::get<1>(args), CALL_ACTUAL_ARGS); } while (detail::select(boost::tuples::get<0>(args), CALL_ACTUAL_ARGS) ); } }; // No body case template
class lambda_functor_base
{ public: Args args; template
struct sig { typedef void type; }; public: explicit lambda_functor_base(const Args& a) : args(a) {} template
RET call(CALL_FORMAL_ARGS) const { do {} while (detail::select(boost::tuples::get<0>(args), CALL_ACTUAL_ARGS) ); } }; // Specialization for if_then. template
class lambda_functor_base
{ public: Args args; template
struct sig { typedef void type; }; public: explicit lambda_functor_base(const Args& a) : args(a) {} template
RET call(CALL_FORMAL_ARGS) const { if (detail::select(boost::tuples::get<0>(args), CALL_ACTUAL_ARGS)) detail::select(boost::tuples::get<1>(args), CALL_ACTUAL_ARGS); } }; // Specialization for if_then_else. template
class lambda_functor_base
{ public: Args args; template
struct sig { typedef void type; }; public: explicit lambda_functor_base(const Args& a) : args(a) {} template
RET call(CALL_FORMAL_ARGS) const { if (detail::select(boost::tuples::get<0>(args), CALL_ACTUAL_ARGS)) detail::select(boost::tuples::get<1>(args), CALL_ACTUAL_ARGS); else detail::select(boost::tuples::get<2>(args), CALL_ACTUAL_ARGS); } }; // Specialization of lambda_functor_base for if_then_else_return. template
class lambda_functor_base
, Args> { public: Args args; template
struct sig { private: typedef typename detail::nth_return_type_sig<1, Args, SigArgs>::type ret1; typedef typename detail::nth_return_type_sig<2, Args, SigArgs>::type ret2; public: typedef typename return_type_2< other_action
, ret1, ret2 >::type type; }; public: explicit lambda_functor_base(const Args& a) : args(a) {} template
RET call(CALL_FORMAL_ARGS) const { return (detail::select(boost::tuples::get<0>(args), CALL_ACTUAL_ARGS)) ? detail::select(boost::tuples::get<1>(args), CALL_ACTUAL_ARGS) : detail::select(boost::tuples::get<2>(args), CALL_ACTUAL_ARGS); } }; } // lambda } // boost #endif // BOOST_LAMBDA_CONTROL_CONSTRUCTS_HPP
control_structures_impl.hpp
Page URL
File URL
Prev
5/20
Next
Download
( 16 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.