Skip to content

Commit b9c2eaa

Browse files
committed
address asciidoc syntax mistakes.
1 parent f5bf799 commit b9c2eaa

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

en/03_Drawing_a_triangle/00_Setup/03_Physical_devices_and_queue_families.adoc

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ void pickPhysicalDevice() {
199199
throw std::runtime_error("failed to find a suitable GPU!");
200200
}
201201
}
202+
----
202203

203204
=== Understanding the nested lambda functions
204205

@@ -209,9 +210,11 @@ The `pickPhysicalDevice()` function above uses several nested lambda functions,
209210
Lambda functions (or lambda expressions) are a C++ feature that allows you to define anonymous functions inline. They're especially useful for short operations that you don't need to define as separate named functions.
210211

211212
The basic syntax of a lambda is:
212-
```cpp
213+
214+
[source,cpp]
215+
----
213216
[capture-list](parameters) { body }
214-
```
217+
----
215218

216219
- The `capture-list` specifies which variables from the surrounding scope are accessible inside the lambda
217220
- `parameters` are the input parameters, just like in regular functions
@@ -221,14 +224,15 @@ The basic syntax of a lambda is:
221224

222225
In our `pickPhysicalDevice()` function, we use `std::ranges::find_if` with a lambda to find the first suitable device:
223226

224-
```cpp
227+
[source,cpp]
228+
----
225229
const auto devIter = std::ranges::find_if(devices,
226230
[&](auto const & device) {
227231
// Lambda body that checks if the device is suitable
228232
// ...
229233
return isSuitable;
230234
});
231-
```
235+
----
232236

233237
The `[&]` capture list means this lambda can access all variables from the
234238
surrounding scope by reference. This is necessary because we need to access
@@ -240,25 +244,27 @@ convenience andclarity as goals in mind.
240244

241245
Inside the main lambda, we have another lambda that checks if a queue family supports graphics operations:
242246

243-
```cpp
247+
[source,cpp]
248+
----
244249
const auto qfpIter = std::ranges::find_if(queueFamilies,
245250
[]( vk::QueueFamilyProperties const & qfp ) {
246251
return (qfp.queueFlags & vk::QueueFlagBits::eGraphics) != static_cast<vk::QueueFlags>(0);
247252
});
248-
```
253+
----
249254

250255
This lambda doesn't need to capture any variables (empty `[]`), as it only uses its parameter `qfp`.
251256

252257
==== Nested lambda for checking extension support
253258

254259
Further down, we have another lambda that checks if a specific extension is supported:
255260

256-
```cpp
261+
[source,cpp]
262+
----
257263
auto extensionIter = std::ranges::find_if(extensions,
258264
[extension](auto const & ext) {
259265
return strcmp(ext.extensionName, extension) == 0;
260266
});
261-
```
267+
----
262268

263269
This lambda captures the `extension` variable by value (`[extension]`) so it can compare it with each available extension.
264270

@@ -276,7 +282,6 @@ While nested lambdas can make code more concise, they can also make it harder
276282
this explanation to help you understand the pattern. Throughout this
277283
tutorial, we will attempt to use only modern C++ to keep with a one language
278284
paradigm for ease of use/familiarity.
279-
----
280285

281286
In the next section, we'll discuss the first real required feature to check for.
282287

0 commit comments

Comments
 (0)