亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? named_params.rst

?? [2005最新C++經(jīng)典著作].C++ Programming.新手必看的學VC的奠基之著。
?? RST
字號:
++++++++++++++++++++++++++++++++++++++++++ The Boost.NamedParams Library |(logo)|__++++++++++++++++++++++++++++++++++++++++++.. |(logo)| image:: ../../../boost.png   :alt: Boost   :class: boost-logo__ ../../../index.htm-------------------------------------:Authors: David Abrahams, Daniel Wallin:Contact: dave@boost-consulting.com, dalwan01@student.umu.se:organizations: `Boost Consulting`_, :date: $Date: 2004/04/17 10:46:07 $:copyright: Copyright David Abrahams, Daniel Wallin 2003. :license: Use, modification and distribution is subject to 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).. _`Boost Consulting`: http://www.boost-consulting.com.. _`Open Systems Lab`: http://www.osl.iu.edu .. contents:: Outline.. section-numbering::Introduction============In C++ function arguments are given meaning by their position inthe parameter list. This protocol is fine when there are fewparameters with default values, but as the number of parametersgrows, so does the inconvenience of passing arguments in thecorrect order, especially in the presence of default values:   * It can become difficult for readers to understand the meaning of     arguments at the call site::       window* w = new_window("alert", true, true, false, 77, 65);   * Since meaning is given by position, we have to choose some     (often arbitrary) order for parameters with default values,     making some combinations of defaults unusable::        window* new_window(            char const* name, bool border = true          , bool opaque = true, bool movable = false          , int width = 100, int height = 100);              const bool movability = true;        window* w = new_window("alert2", movability); // error!   * Default values can not depend on the values of other function     parameters::        window* new_window(            char const* name, bool border, ...          , int width = 100, int heigh = width); // error!   * Template types can not be deduced from the default values, so     we have to resort to overloading to provide default values for     parameters with template type::        template<class T> void f(T x = 0);        f(); // error!This library is an attempt to address the problems outlined aboveby associating each parameter with a keyword identifier.  Usingthis library, users can identify parameters by name instead of justargument position::  window* w = new_window("alert2", movable = movability); // OK!.. DWA Daniel, we explicitly *don't* need ref() for the case   described below.  It's only when we want to pass by reference   without a keyword that we need it.   You also can't start talking about forwarding functions without   introducing them first!   The tutorial has to come before all the nasty details below.   I'm going to comment on that and leave the next stuff aloneTutorial ========.. DWA you need some set-up here describing the problem you're   going to solve.This example shows how to wrap a function::    void foo(char const* name, float value);to give both parameters names and default values.Defining the keywords---------------------First we define the named parameter keywords. This is done by creating"tag" types for each keyword, and declaring ``keyword<``\ *tag*\``>`` objects::     #include <boost/named_params.hpp>     struct name_t; // tag types     struct value_t;     namespace {       boost::keyword<name_t> name;    // keyword objects       boost::keyword<value_t> value;     }Placing these keyword objects in an unnamed namespace will preventlink errors when you declare keywords in header files [**Note**:the tag types should generally *not* be declared in an unnamednamespace].  We also need to create a keywords list for ourfunction.  These keywords should be declared in the same order astheir corresponding parameters appear in the function's parameterlist::     struct foo_keywords       : boost::keywords<             name_t           , value_t         >     {};Defining the forwarding functions---------------------------------::     template<class Params>     void foo_impl(const Params&);     void foo()     {         foo_impl(foo_keywords()());     }     template<class A0>     void foo(const A0& a0)     {         foo_impl(foo_keywords()(a0));     }     template<class A0, class A1>     void foo(const A0& a0, const A1& a1)     {         foo_impl(foo_keywords()(a0, a1));     }Defining the implementation function------------------------------------::     template<class Params>     void foo_impl(const Params& params)     {         std::cout << params[name] << " = " << params[value] << "\n";     }That's it. The user calls the ``foo()`` forwarding functions, witheither positional or named parameters. For instance::     foo("bar", 3.14f);     foo(value = 6.28f, "baz")Should print::     bar = 3.14     baz = 6.28But we still don't have any default values, leaving any of theparameters out results in a compilation error::     foo()     foo("bar")     foo(value = 3)All fails.Fortunatly, adding default values to parameters is easy::     template<class Params>     void foo_impl(const Params& params)     {         std::cout             << params[name | "unnamed"] << " = "             << params[value | 0] << "\n";     }We are using ``operator|`` to denote the default value of a namedparameter.Going back a little to the ``foo()`` call that didn't compile::     foo()     foo("bar")     foo(value = 3)Now compiles, and prints::     unnamed = 0     bar = 0     unnamed = 3Limitations of the Approach===========================Because the keywords' ``operator=`` returns a temporary, andtemporaries cannot be bound to non-``const`` reference parameters,our forwarding functions need to take their arguments by ``const``reference [#forwarding]_. As a result, an argument which is boundto a keyword with ``operator=`` can be transparently passed bynon-const reference, but positional arguments are always passed by``const`` reference unless we use the `Boost.Ref`_ library toindicate otherwise::    #include <boost/ref.hpp>    float x;    foo(value = x);     // held type is float&    foo(x);             // held type is float const&, need help!    foo(boost::ref(x)); // held type is float&.. _`Boost.Ref`: ../../bind/ref.hppInstances of ``boost::reference_wrapper<>`` generated by``boost::ref`` will be unwrapped automatically by the library.Controlling Overload Resolution===============================The parameters of our templated forwarding functions are completelygeneral; in fact, they're a perfect match for any argument typewhatsoever.  The problems with exposing such general functiontemplates have been the subject of much discussion; especially inthe presence of `unqualified calls`__.  Probably the safest thingto do is to isolate the forwarding functions in a namespacecontaining no types [#using]_, but often we'd *like* our functionsto play nicely with argument-dependent lookup and other functionoverloads.  In that case, it's neccessary to somehow remove thefunctions from the overload set when the passed argument typesdon't meet their needs.__ http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/lwg-defects.html#225This sort of overload control can be accomplished in C++ by takingadvantage of SFINAE_ (Substitution Failure Is Not An Error). Iftype substitution during the instantiation of a function templateresults in an invalid type, no compilation error is emitted;instead the overload is removed from the overload set. By producingan invalid type in the function signature depending on the resultof some condition, whether or not an overload is considered duringoverload resolution can be controlled.  The technique is formalizedin the |enable_if| utility.The named parameters library provides built-in SFINAE supportthrough the following class template::     template<         class KeywordTag       , class HasDefaultValue // mpl::true_ or mpl::false_       , class Predicate     >     struct named_param;The key parameter, ``Predicate`` shall be a unary MPL lambdaexpression or `Metafunction Class`_ that, when applied to theactual type the argument, indicates whether that argument typemeets the function's requirements for that parameter position... _`Metafunction Class`: ../../mpl/doc/ref/Metafunction_Class.html.. _SFINAE: http://www.semantics.org/once_weakly/w02_SFINAE.pdf.. |enable_if| replace:: ``enable_if``.. _enable_if: ../enable_if.htmlFor example, let's say we want to restrict our ``foo()`` so thatthe ``name`` parameter must be convertible to ``const char*``.We'll replace our use of the ``name_t`` tag with a specializationof ``boost::named_param``:.. parsed-literal::     struct foo_keywords       : boost::keywords<             **boost::named_param<                 name_t               , mpl::false\_               , is_convertible<mpl::\_, const char\*>             >**           , value_t         >     {};Now we can add an additional optional argument to each of our``foo`` overloads.. parsed-literal::     template<class A0>     void foo(         const A0& a0       , **foo_keywords::restrict<A0>::type x = foo_keywords()**     )     {         foo_impl(x(a0));     }     template<class A0, class A1>     void foo(         const A0& a0, const A1& a1       , **foo_keywords::restrict<A0,A1>::type x = foo_keywords()**     )     {         foo_impl(x(a0, a1));     }These additional parameters are not intended to be used directlyby callers; they merely trigger SFINAE by becoming illegal typeswhen the ``name`` argument is not convertible to ``const char*``.Lazy Evaluation of Defaults===========================If computing an argument's default value is expensive, it's bestavoided when the argument is supplied by the user. In that case,the default value can be lazily evaluated using the followingsyntax:.. parsed-literal::    params[keyword **|| nullary_function**];``nullary_function`` must be a function object that is callablewithout arguments, and that indicates its return type via a nested``result_type``.  Boost.Bind can be used to produce an appropriatefunction object from a regular function pointer::  // expensive default computation function  float default_span(float x, float theta);  // implementation of bar()  template <class Params>  void bar_impl(Params const& params)  {      // Extract arguments      float x_ = params[x];      float theta_ = params[theta | pi];      float span = params[span || boost::bind(default_span, x_, theta_)];      ...  }Automatic Overload Generation=============================To reduce the work needed to write functions with named parameters,we supply a macro that generates the boilerplate code.Synopsis::     BOOST_NAMED_PARAMS_FUN(         return_type, function_name       , min_arity, max_arity, keywords_type     );To generate all the forwarding functions and the implementationfunction for our example, we need only apply``BOOST_NAMED_PARAMS_FUN`` this way::     BOOST_NAMED_PARAMS_FUN(void, foo, 0, 2, foo_keywords)     {         std::cout             << p[name | "unnamed"] << " = "             << p[value | 0] << "\n";     }Portability===========Boost.NamedParams has been confirmed to work on the following compilers:   - Microsoft VC6 sp5, VC7 [#norestrict]_   - Microsoft VC7.1   - GCC3.3.1 (cygwin), GCC2.95.3 (cygwin), GCC3.2 (mingw)   - Metrowerks Codewarrior Pro8 and Pro9 (Windows)   - Intel C++ 5.0,6.0,7.1,8.0 (Windows)   - Comeau 4.3.3-----------------------------.. [#forwarding] One could provide overloads for ``const`` and   non-``const`` reference versions of each parameter, but that   would quickly become unmanageable.  It's known as "the   forwarding problem" and has been described in detail in this   paper__.  The combinatorial explosion is avoided for the   parameter of keywords' ``operator=`` because they take only a   single argument.   __ http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2002/n1385.htm.. [#using] You can always give the illusion that the function   lives in an outer namespace by applying a *using-declaration*::      namespace foo_overloads      {        // foo declarations here        void foo() { ... }        ...      }      using foo_overloads::foo;  .. [#norestrict] Restrictions doesn't work on these compilers because   of lack of SFINAE support.

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
中文一区二区在线观看| 国产寡妇亲子伦一区二区| 色综合久久66| 亚洲女子a中天字幕| 91在线porny国产在线看| 亚洲视频在线观看一区| 色偷偷久久一区二区三区| 亚洲欧美色一区| 欧美在线观看一区| 日日欢夜夜爽一区| 欧美成人精品高清在线播放| 美美哒免费高清在线观看视频一区二区 | 欧美老年两性高潮| 日本不卡视频一二三区| 欧美成人性福生活免费看| 国产一区二区精品久久99| 国产精品久久影院| 欧美日韩在线直播| 老司机一区二区| 国产精品嫩草久久久久| 欧美系列亚洲系列| 国产综合色产在线精品| 一区视频在线播放| 欧美麻豆精品久久久久久| 精品一区二区三区在线观看| 亚洲国产成人在线| 欧美日韩色综合| 国产精品99久久久久久久vr| 亚洲欧洲综合另类| 日韩精品中文字幕在线一区| www.激情成人| 免费观看30秒视频久久| 中文字幕永久在线不卡| 日韩一级片在线播放| 成人国产视频在线观看| 免费在线观看精品| 亚洲免费观看高清完整版在线| 欧美妇女性影城| 99这里只有精品| 美洲天堂一区二卡三卡四卡视频| 国产精品久久久久影院亚瑟 | 中文一区二区在线观看| 欧美巨大另类极品videosbest| 国产成人午夜电影网| 香蕉av福利精品导航| 国产精品麻豆99久久久久久| 日韩欧美的一区| 欧美最猛黑人xxxxx猛交| 国产宾馆实践打屁股91| 三级久久三级久久久| 亚洲区小说区图片区qvod| 欧美精品一区二区三区蜜臀| 欧美日韩一区二区三区四区| 不卡的av在线| 国产精品一区二区久久精品爱涩 | 午夜免费久久看| 国产精品国产三级国产| 精品国产伦一区二区三区免费| 欧美三级在线播放| 91免费版在线| 成人av影视在线观看| 极品少妇一区二区三区精品视频| 亚洲成av人在线观看| 亚洲久本草在线中文字幕| 中文字幕乱码亚洲精品一区| 欧美大片在线观看一区二区| 欧美老女人第四色| 欧美人与禽zozo性伦| 欧美色偷偷大香| 在线精品视频免费播放| 91行情网站电视在线观看高清版| 粉嫩aⅴ一区二区三区四区| 国产一区不卡在线| 国产一区二区伦理片| 国内精品在线播放| 久久99国产精品久久| 久久se这里有精品| 开心九九激情九九欧美日韩精美视频电影 | 日韩一区二区三区视频在线| 欧美高清精品3d| 91.com视频| 精品久久久久久最新网址| 欧美精品一区二区三区四区| 国产亚洲精品福利| 中文字幕欧美国产| 一区二区三区在线视频免费观看| 亚洲免费av网站| 亚洲成a天堂v人片| 青青草国产精品亚洲专区无| 免费精品视频最新在线| 激情伊人五月天久久综合| 国产伦精品一区二区三区免费迷| 国产精品一区在线| 99久久精品一区二区| 欧美自拍偷拍一区| 欧美一区二区免费观在线| 精品国精品自拍自在线| 日本一区二区电影| 亚洲精品中文字幕乱码三区| 亚洲国产综合91精品麻豆| 免费日韩伦理电影| 成人精品在线视频观看| 日本伦理一区二区| 欧美一区日本一区韩国一区| 久久日韩精品一区二区五区| 国产精品白丝在线| 亚洲成a人在线观看| 国内精品视频666| 99视频国产精品| 欧美精品成人一区二区三区四区| 精品久久久久久久久久久久久久久 | 亚洲欧美日韩小说| 肉色丝袜一区二区| 国产成人在线免费观看| 91黄色小视频| 久久综合久久久久88| 亚洲免费av高清| 国产中文字幕一区| 91精彩视频在线| 国产性做久久久久久| 亚洲综合小说图片| 国产一区二区免费视频| 欧美午夜影院一区| 久久久久久久久久久黄色| 亚洲男同1069视频| 国产主播一区二区三区| 欧美日韩综合在线免费观看| 国产香蕉久久精品综合网| 亚洲综合色丁香婷婷六月图片| 久草精品在线观看| 欧美色图在线观看| 国产亚洲欧美中文| 日韩专区在线视频| 91女厕偷拍女厕偷拍高清| 欧美大度的电影原声| 一个色在线综合| 国产成人免费视频一区| 日韩一级免费一区| 亚洲国产另类av| 97久久精品人人澡人人爽| 精品久久人人做人人爽| 午夜欧美2019年伦理| av亚洲精华国产精华精| 欧美精品一区二区在线播放| 日韩 欧美一区二区三区| 在线一区二区三区| 国产精品网站一区| 黑人巨大精品欧美一区| 在线播放91灌醉迷j高跟美女 | 日日夜夜精品视频天天综合网| 不卡视频免费播放| 国产欧美日韩中文久久| 韩国v欧美v亚洲v日本v| 日韩视频在线观看一区二区| 天天综合网 天天综合色| 欧洲亚洲精品在线| 亚洲人123区| 色综合色综合色综合| 国产精品麻豆欧美日韩ww| 成人一区在线观看| 久久久久国产精品麻豆ai换脸| 美女视频黄 久久| 日韩欧美资源站| 人禽交欧美网站| 欧美成人video| 蜜桃在线一区二区三区| 日韩午夜中文字幕| 青娱乐精品视频| 欧美电影免费观看高清完整版| 裸体健美xxxx欧美裸体表演| 日韩欧美精品三级| 免费成人性网站| 欧美变态口味重另类| 狠狠色丁香婷婷综合| 欧美精品一区二区三区四区| 国产精品99久久久久久久女警| 国产女主播视频一区二区| 国产成人在线视频免费播放| 中文字幕一区二区三区四区不卡| aa级大片欧美| 一区二区国产视频| 在线播放一区二区三区| 美国一区二区三区在线播放| 久久综合九色综合97婷婷| 福利一区二区在线| 亚洲色图制服诱惑| 色狠狠一区二区| 午夜精品久久久久久久久| 日韩欧美一二三| 国产精品系列在线观看| 日韩理论电影院| 欧美另类一区二区三区| 久久66热re国产| 国产精品久久久久久久久免费丝袜| 97久久精品人人澡人人爽| 视频在线观看一区| 欧美国产一区在线| 欧美天天综合网| 国产麻豆视频精品| 亚洲精品精品亚洲|