回答編集履歴
6
二次元配列追記
test
CHANGED
@@ -49,3 +49,23 @@
|
|
49
49
|
}
|
50
50
|
|
51
51
|
```
|
52
|
+
|
53
|
+
---
|
54
|
+
|
55
|
+
> 二次元配列(std::array<std::array<std::string, 3>, 4>のようなもの
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
```C++
|
60
|
+
|
61
|
+
template<template<class, size_t>typename T, size_t Size1, size_t Size2, std::enable_if_t<is_container_v<std::remove_reference_t<T<std::string, Size1>>>, std::nullptr_t> = nullptr>
|
62
|
+
|
63
|
+
auto f(T< T<std::string, Size1>, Size2>)
|
64
|
+
|
65
|
+
{
|
66
|
+
|
67
|
+
std::cout << "call specialization Size1:" << Size1 << " Size2:" << Size2 << std::endl;
|
68
|
+
|
69
|
+
}
|
70
|
+
|
71
|
+
```
|
5
コンテナ以外も渡せていたのを修正
test
CHANGED
@@ -12,9 +12,23 @@
|
|
12
12
|
|
13
13
|
```
|
14
14
|
|
15
|
+
---
|
16
|
+
|
17
|
+
コンテナ判別が漏れていました…
|
18
|
+
|
19
|
+
```C++
|
20
|
+
|
21
|
+
template<template<class Elem, class = std::allocator<Elem>>typename T, std::enable_if_t<is_container_v<std::remove_reference_t<T<std::string>>>, std::nullptr_t> = nullptr>
|
22
|
+
|
23
|
+
auto f(T<std::string>) {
|
24
|
+
|
25
|
+
std::cout << "call specialization" << std::endl;
|
26
|
+
|
27
|
+
}
|
28
|
+
|
29
|
+
```
|
15
30
|
|
16
31
|
|
17
|
-
---
|
18
32
|
|
19
33
|
> std::arrayにも対応させる
|
20
34
|
|
4
ビルドエラー修正
test
CHANGED
@@ -24,7 +24,7 @@
|
|
24
24
|
|
25
25
|
```C++
|
26
26
|
|
27
|
-
template<template<class, size_t>typename T, size_t Size, std::enable_if_t<is_container_v<std::remove_reference_t<T>>, std::nullptr_t> = nullptr>
|
27
|
+
template<template<class, size_t>typename T, size_t Size, std::enable_if_t<is_container_v<std::remove_reference_t<T<std::string, Size>>>, std::nullptr_t> = nullptr>
|
28
28
|
|
29
29
|
auto f(T<std::string, Size>)
|
30
30
|
|
3
コンテナ以外も渡せていたのを修正
test
CHANGED
@@ -24,7 +24,7 @@
|
|
24
24
|
|
25
25
|
```C++
|
26
26
|
|
27
|
-
template<template<class, size_t>typename T, size_t Size>
|
27
|
+
template<template<class, size_t>typename T, size_t Size, std::enable_if_t<is_container_v<std::remove_reference_t<T>>, std::nullptr_t> = nullptr>
|
28
28
|
|
29
29
|
auto f(T<std::string, Size>)
|
30
30
|
|
2
const除去
test
CHANGED
@@ -24,7 +24,7 @@
|
|
24
24
|
|
25
25
|
```C++
|
26
26
|
|
27
|
-
template<template<class, size_t>typename T,
|
27
|
+
template<template<class, size_t>typename T, size_t Size>
|
28
28
|
|
29
29
|
auto f(T<std::string, Size>)
|
30
30
|
|
1
std::array対応追加
test
CHANGED
@@ -11,3 +11,27 @@
|
|
11
11
|
}
|
12
12
|
|
13
13
|
```
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
---
|
18
|
+
|
19
|
+
> std::arrayにも対応させる
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
こんな感じ?
|
24
|
+
|
25
|
+
```C++
|
26
|
+
|
27
|
+
template<template<class, size_t>typename T, const size_t Size>
|
28
|
+
|
29
|
+
auto f(T<std::string, Size>)
|
30
|
+
|
31
|
+
{
|
32
|
+
|
33
|
+
std::cout << "call specialization size:" << Size << std::endl;
|
34
|
+
|
35
|
+
}
|
36
|
+
|
37
|
+
```
|