Карта сайта Kansoftware
НОВОСТИУСЛУГИРЕШЕНИЯКОНТАКТЫ
Разработка программного обеспечения

Boost.Hana: boost::hana::pair< First, Second > Struct Template Reference

Boost , ,

Boost.Hana  1.0.1
Your standard library for metaprogramming
Общий контейнер для двух элементов.

<hana::pair>концептуально то же самое, что и<std::pair>. Однако<hana::pair>автоматически сжимает хранилище пустых типов, и в результате у него нет членов<.first>и<.second>. Вместо этого необходимо использовать функции<hana::first>и<hana::second>для доступа к элементам пары.

Modeled concepts

  1. Comparable
    Две пары(x, y)и '(x', y')are equal if and only if bothx == x'andy == y'.
    // Авторское право Louis Dionne 2013-2016
    // Распространяется под лицензией Boost Software License, версия 1.0.
    // (См. сопроводительный файл LICENSE.md или копию на http://boost.org/LICENSE_1_0.txt)
    #include<boost/hana/not_equal.hpp>
    пространство именhana =boost::hana;
    static_assert(hana::make_pair(1,& #39;x') == hana::make_pair(1,& #39;x'),"");
    static_assert(hana::make_pair(2,& #39;x') != hana::make_pair(1,& #39;x'),"");
    static_assert(hana::make_pair(1,'y');) != hana::make_pair(1,'x'),"";
    intmain()
    [ORIG_END] -->
  2. Orderable
    Пары упорядочены так, как если бы они были 2-элементными кортежами, с использованием лексикографического упорядочения.
    // Авторское право Louis Dionne 2013-2016
    // Распространяется по лицензии Boost Software License, версия 1.0.
    // (См. сопроводительный файл LICENSE.md или копию по адресу http://boost.org/LICENSE_1_0.txt)
    static_assert(hana::make_pair(1,& #39;],""],
    static_assert(1,""],
    static_assert(1,& #39;],"1,& #39;],
    ],
    , [[ORIG_END] -->
  3. Foldable
    Складка пары эквивалентна складыванию 2-элементного кортежа. Другими словами:
    fold_leftmake_pair(x, y), s, f) == f(f(s, x), y)
    fold_rightmake_pair(x, y), s, f) == f(x, f(y, s)]
    Пример:
    // Авторское право Louis Dionne 2013-2016
    // Распространяется по лицензии Boost Software License, Version 1.0.
    // [См. сопроводительный файл LICENSE.md или копию по адресу http://boost.org/LICENSE_1_0.txt]
    Example:
    // Copyright Louis Dionne 2013-2016
    // Distributed under the Boost Software License, Version 1.0.
    // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
    namespace hana = boost::hana;
    static_assert(hana::fold_left(hana::make_pair(1, 3), 0, hana::plus) == 4, "");
    static_assert(hana::fold_right(hana::make_pair(1, 3), 0, hana::minus) == -2, "");
    int main() { }
    [ORIG_END] -->
  4. Product
    МодельProduct— самая простая из возможных; первый элемент пары(x, y)x, а второй её элемент —y.
    // Авторское право Louis Dionne 2013-2016
    // Распространяется по лицензии Boost Software License, Version 1.0.
    // (См. сопроводительный файл LICENSE.md или копию по адресу http://boost.org/LICENSE_1_0.txt)
    ] == 1,"" [ORIG_END] -->

Synopsis of associated functions

template<>
constexpr auto make< pair_tag >
 Creates a hana::pair with the given elements. More...
 
constexpr auto make_pair = make<pair_tag>
 Alias to make<pair_tag>; provided for convenience. More...
 

Friends

template<typename X , typename Y >
constexpr auto operator== (X &&x, Y &&y)
 Equivalent to hana::equal
 
template<typename X , typename Y >
constexpr auto operator!= (X &&x, Y &&y)
 Equivalent to hana::not_equal
 
template<typename X , typename Y >
constexpr auto operator< (X &&x, Y &&y)
 Equivalent to hana::less
 
template<typename X , typename Y >
constexpr auto operator> (X &&x, Y &&y)
 Equivalent to hana::greater
 
template<typename X , typename Y >
constexpr auto operator<= (X &&x, Y &&y)
 Equivalent to hana::less_equal
 
template<typename X , typename Y >
constexpr auto operator>= (X &&x, Y &&y)
 Equivalent to hana::greater_equal
 

Public Member Functions

constexpr pair ()
 Default constructs the pair. Only exists when both elements of the pair are default constructible.
 
constexpr pair (First const &first, Second const &second)
 Initialize each element of the pair with the corresponding element. Only exists when both elements of the pair are copy-constructible.
 
template<typename T , typename U >
constexpr pair (T &&t, U &&u)
 Initialize both elements of the pair by perfect-forwarding the corresponding argument. Only exists when both arguments are implicitly-convertible to the corresponding element of the pair.
 
template<typename T , typename U >
constexpr pair (pair< T, U > const &other)
 Copy-initialize a pair from another pair. Only exists when both elements of the source pair are implicitly convertible to the corresponding element of the constructed pair.
 
template<typename T , typename U >
constexpr pair (pair< T, U > &&other)
 Move-initialize a pair from another pair. Only exists when both elements of the source pair are implicitly convertible to the corresponding element of the constructed pair.
 
template<typename T , typename U >
constexpr pairoperator= (pair< T, U > const &other)
 Assign a pair to another pair. Only exists when both elements of the destination pair are assignable from the corresponding element in the source pair.
 
template<typename T , typename U >
constexpr pairoperator= (pair< T, U > &&other)
 Move-assign a pair to another pair. Only exists when both elements of the destination pair are move-assignable from the corresponding element in the source pair.
 

Associated functions

template<typename First, typename Second>
template<>
constexpr auto make< pair_tag >
related
Initial value:
= [](auto&& first, auto&& second)
-> hana::pair<std::decay_t<decltype(first)>, std::decay_t<decltype(second)>>
{
return {forwarded(first), forwarded(second)};
}

Создает<hana::pair>с данными элементами.

Example

// Copyright Louis Dionne 2013-2016
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
namespace hana = boost::hana;
static_assert(hana::first(hana::make<hana::pair_tag>(1, 'x')) == 1, "");
static_assert(hana::second(hana::make<hana::pair_tag>(1, 'x')) == 'x', "");
static_assert(hana::make_pair(1, 'x') == hana::make<hana::pair_tag>(1, 'x'), "");
int main() { }
template<typename First, typename Second>
constexpr auto make_pair = make<pair_tag>
related

<make<pair_tag>>Для удобства.

Example

// Copyright Louis Dionne 2013-2016
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
namespace hana = boost::hana;
static_assert(hana::first(hana::make<hana::pair_tag>(1, 'x')) == 1, "");
static_assert(hana::second(hana::make<hana::pair_tag>(1, 'x')) == 'x', "");
static_assert(hana::make_pair(1, 'x') == hana::make<hana::pair_tag>(1, 'x'), "");
int main() { }

Статья Boost.Hana: boost::hana::pair< First, Second > Struct Template Reference раздела может быть полезна для разработчиков на c++ и boost.




Материалы статей собраны из открытых источников, владелец сайта не претендует на авторство. Там где авторство установить не удалось, материал подаётся без имени автора. В случае если Вы считаете, что Ваши права нарушены, пожалуйста, свяжитесь с владельцем сайта.



:: Главная :: ::


реклама


©KANSoftWare (разработка программного обеспечения, создание программ, создание интерактивных сайтов), 2007
Top.Mail.Ru

Время компиляции файла: 2024-08-30 11:47:00
2025-05-19 21:10:19/0.0073199272155762/0