• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1.. Metafunctions/Miscellaneous//always |20
2
3always
4======
5
6Synopsis
7--------
8
9.. parsed-literal::
10
11    template<
12          typename X
13        >
14    struct always
15    {
16        // |unspecified|
17        // |...|
18    };
19
20
21Description
22-----------
23
24``always<X>`` specialization is a variadic |Metafunction Class| always returning the
25same type, ``X``, regardless of the number and types of passed arguments.
26
27
28Header
29------
30
31.. parsed-literal::
32
33    #include <boost/mpl/always.hpp>
34
35Model of
36--------
37
38|Metafunction Class|
39
40
41Parameters
42----------
43
44+---------------+-------------------+-----------------------------------+
45| Parameter     | Requirement       | Description                       |
46+===============+===================+===================================+
47| ``X``         | Any type          | A type to be returned.            |
48+---------------+-------------------+-----------------------------------+
49
50
51Expression semantics
52--------------------
53
54For an arbitrary type ``x``:
55
56
57.. parsed-literal::
58
59    typedef always<x> f;
60
61:Return type:
62    |Metafunction Class|.
63
64:Semantics:
65    Equivalent to
66
67    .. parsed-literal::
68
69        struct f : bind< identity<_1>, x > {};
70
71
72Example
73-------
74
75.. parsed-literal::
76
77    typedef always<true\_> always_true;
78
79    BOOST_MPL_ASSERT(( apply< always_true,false\_> ));
80    BOOST_MPL_ASSERT(( apply< always_true,false\_,false\_ > ));
81    BOOST_MPL_ASSERT(( apply< always_true,false\_,false\_,false\_ > ));
82
83
84See also
85--------
86
87|Metafunctions|, |Metafunction Class|, |identity|, |bind|, |apply|
88
89
90.. copyright:: Copyright �  2001-2009 Aleksey Gurtovoy and David Abrahams
91   Distributed under the Boost Software License, Version 1.0. (See accompanying
92   file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
93