feat: add structured binding test
This commit is contained in:
parent
88742436a1
commit
543b4b832a
4 changed files with 36 additions and 11 deletions
|
@ -1,5 +1,5 @@
|
|||
add_library(chapter_02 src/initlist.cpp src/null.cpp src/constexp.cpp
|
||||
src/ifswitch.cpp)
|
||||
src/ifswitch.cpp src/structured_binding.cpp)
|
||||
|
||||
target_compile_features(chapter_02 PUBLIC cxx_std_20)
|
||||
|
||||
|
|
8
chapters/chapter_02/include/structured_binding.h
Normal file
8
chapters/chapter_02/include/structured_binding.h
Normal file
|
@ -0,0 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
#include "chapter_interface.h"
|
||||
|
||||
class StructuredBindingTest : public ChapterTest {
|
||||
public:
|
||||
virtual void run() override;
|
||||
};
|
12
chapters/chapter_02/src/structured_binding.cpp
Normal file
12
chapters/chapter_02/src/structured_binding.cpp
Normal file
|
@ -0,0 +1,12 @@
|
|||
#include "structured_binding.h"
|
||||
#include <cstdint>
|
||||
#include <iostream>
|
||||
#include <tuple>
|
||||
|
||||
std::tuple<const char *, uint32_t> func() { return {"32", 32}; }
|
||||
|
||||
void StructuredBindingTest::run() {
|
||||
const auto &[str, val] = func();
|
||||
|
||||
std::cout << "Bound values: " << str << " and " << val << std::endl;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue