Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenDocCN
TinySTL
提交
721dca3e
T
TinySTL
项目概览
OpenDocCN
/
TinySTL
通知
4
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TinySTL
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
721dca3e
编写于
11月 05, 2014
作者:
邹
邹晓航
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
添加对pair的test
上级
d779a9dc
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
52 addition
and
0 deletion
+52
-0
TinySTL/Test/PairTest.cpp
TinySTL/Test/PairTest.cpp
+45
-0
TinySTL/TinySTL.vcxproj
TinySTL/TinySTL.vcxproj
+1
-0
TinySTL/TinySTL.vcxproj.filters
TinySTL/TinySTL.vcxproj.filters
+6
-0
未找到文件。
TinySTL/Test/PairTest.cpp
0 → 100644
浏览文件 @
721dca3e
#include <iostream>
#include "..\Utility.h"
#include "..\String.h"
using
namespace
TinySTL
;
int
main
(){
// test ctor
pair
<
string
,
double
>
product1
;
// default constructor
pair
<
string
,
double
>
product2
(
"tomatoes"
,
2.30
);
// value init
pair
<
string
,
double
>
product3
(
product2
);
// copy constructor
product1
=
make_pair
(
string
(
"lightbulbs"
),
0.99
);
// using make_pair (move)
product2
.
first
=
"shoes"
;
// the type of first is string
product2
.
second
=
39.90
;
// the type of second is double
std
::
cout
<<
"The price of "
<<
product1
.
first
<<
" is $"
<<
product1
.
second
<<
'\n'
;
std
::
cout
<<
"The price of "
<<
product2
.
first
<<
" is $"
<<
product2
.
second
<<
'\n'
;
std
::
cout
<<
"The price of "
<<
product3
.
first
<<
" is $"
<<
product3
.
second
<<
'\n'
;
//test operator =
pair
<
string
,
int
>
planet
,
homeplanet
;
planet
=
make_pair
(
string
(
"Earth"
),
6371
);
homeplanet
=
planet
;
std
::
cout
<<
"Home planet: "
<<
homeplanet
.
first
<<
'\n'
;
std
::
cout
<<
"Planet size: "
<<
homeplanet
.
second
<<
'\n'
;
//test swap
pair
<
int
,
char
>
foo1
(
10
,
'a'
);
pair
<
int
,
char
>
bar1
(
90
,
'z'
);
//foo1.swap(bar1);
swap
(
foo1
,
bar1
);
std
::
cout
<<
"foo contains: "
<<
foo1
.
first
;
std
::
cout
<<
" and "
<<
foo1
.
second
<<
'\n'
;
//test relational operators
pair
<
int
,
char
>
foo
(
10
,
'z'
);
pair
<
int
,
char
>
bar
(
90
,
'a'
);
if
(
foo
==
bar
)
std
::
cout
<<
"foo and bar are equal
\n
"
;
if
(
foo
!=
bar
)
std
::
cout
<<
"foo and bar are not equal
\n
"
;
if
(
foo
<
bar
)
std
::
cout
<<
"foo is less than bar
\n
"
;
if
(
foo
>
bar
)
std
::
cout
<<
"foo is greater than bar
\n
"
;
if
(
foo
<=
bar
)
std
::
cout
<<
"foo is less than or equal to bar
\n
"
;
if
(
foo
>=
bar
)
std
::
cout
<<
"foo is greater than or equal to bar
\n
"
;
system
(
"pause"
);
return
0
;
}
\ No newline at end of file
TinySTL/TinySTL.vcxproj
浏览文件 @
721dca3e
...
...
@@ -81,6 +81,7 @@
<ItemGroup>
<ClCompile
Include=
"main.cpp"
/>
<ClCompile
Include=
"Profiler\Profiler.cpp"
/>
<ClCompile
Include=
"Test\PairTest.cpp"
/>
</ItemGroup>
<ItemGroup>
<ClInclude
Include=
"Algorithm.h"
/>
...
...
TinySTL/TinySTL.vcxproj.filters
浏览文件 @
721dca3e
...
...
@@ -16,6 +16,9 @@
<Filter
Include=
"头文件\Profiler"
>
<UniqueIdentifier>
{092c2875-2b56-404b-977e-a9b4aa67c134}
</UniqueIdentifier>
</Filter>
<Filter
Include=
"Test"
>
<UniqueIdentifier>
{102ada31-2e23-4fa3-b913-81e7e40d12a7}
</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile
Include=
"main.cpp"
>
...
...
@@ -24,6 +27,9 @@
<ClCompile
Include=
"Profiler\Profiler.cpp"
>
<Filter>
头文件\Profiler
</Filter>
</ClCompile>
<ClCompile
Include=
"Test\PairTest.cpp"
>
<Filter>
Test
</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude
Include=
"TypeTraits.h"
>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录