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

The MPL Reference Manual: insert

Boost , ,

Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

Front Page / Sequences / Intrinsic Metafunctions / insert

insert

Synopsis

template<
      typename Sequence
    , typename Pos
    , typename T
    >
struct insert
{
    typedef unspecified type;
};
template<
      typename Sequence
    , typename T
    >
struct insert
{
    typedef unspecified type;
};

Description

Вставить— перегруженное имя.:

Parameters

Parameter Requirement Description
Последовательность Расширяемая последовательностьилиРасширяемая ассоциативная последовательность Последовательность для вставки.
Пос Передний итератор Итератор вПоследовательность, определяющая положение вставки.
Т Любой тип Элемент должен быть вставлен.

Expression semantics

For any Extensible Sequence s, iterator pos in s, and arbitrary type x:

typedef insert<s,pos,x>::type r;
Return type:

Расширяемая последовательность

Precondition:

pos is an iterator in s.

Semantics:

r is a sequence, concept-identical to s, of the following elements: [begin<s>::type, pos), x, [pos, end<s>::type).

Postcondition:

The relative order of the elements in r is the same as in s.

at< r, distance< begin<s>::type,pos >::type >::type

x;

size<r>::value == size<s>::value + 1;

For any Extensible Associative Sequence s, iterator pos in s, and arbitrary type x:

typedef insert<s,x>::type r;
Return type:Расширяемая ассоциативная последовательность
Semantics:r is concept-identical and equivalent to s, except that at< r, key_type<s,x>::type >::type is identical to value_type<s,x>::type.
Postcondition:size<r>::value == size<s>::value + 1.
typedef insert<s,pos,x>::type r;
Return type:Расширяемая ассоциативная последовательность
Precondition:pos is an iterator in s.
Semantics:Equivalent to typedef insert<s,x>::type r; pos is ignored.

Complexity

Sequence archetype Complexity
Расширяемая ассоциативная последовательность Амортизированное постоянное время.
Расширяемая последовательность Линейное в худшем случае, или амортизированное постоянное время.

Example

typedef vector_c<int,0,1,3,4,5,6,7,8,9> numbers;
typedef find< numbers,integral_c<int,3> >::type pos;
typedef insert< numbers,pos,integral_c<int,2> >::type range;
BOOST_MPL_ASSERT_RELATION( size<range>::value, ==, 10 );
BOOST_MPL_ASSERT(( equal< range,range_c<int,0,10> > ));
typedef map< mpl::pair<int,unsigned> > m;
typedef insert<m,mpl::pair<char,long> >::type m1;
BOOST_MPL_ASSERT_RELATION( size<m1>::value, ==, 2 );
BOOST_MPL_ASSERT(( is_same< at<m1,int>::type,unsigned > ));
BOOST_MPL_ASSERT(( is_same< at<m1,char>::type,long > ));

Статья The MPL Reference Manual: insert раздела может быть полезна для разработчиков на c++ и boost.




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



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


реклама


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

Время компиляции файла: 2024-08-30 11:47:00
2025-05-19 22:37:07/0.0087790489196777/1