Exercises: Add interceptor library
This commit is contained in:
12
exercises/task22/CMakeLists.txt
Normal file
12
exercises/task22/CMakeLists.txt
Normal file
@@ -0,0 +1,12 @@
|
||||
cmake_minimum_required(VERSION 3.8)
|
||||
project(example LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
add_library(foo SHARED libFoo/foo.cpp)
|
||||
target_include_directories(foo PUBLIC libFoo)
|
||||
|
||||
add_executable(executable executable.cpp)
|
||||
target_link_libraries(executable foo)
|
9
exercises/task22/executable.cpp
Normal file
9
exercises/task22/executable.cpp
Normal file
@@ -0,0 +1,9 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "foo.hpp"
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cout << "Random Number: " << foo::random_number() << "\n\n";
|
||||
foo::just_a_print();
|
||||
}
|
23
exercises/task22/libFoo/foo.cpp
Normal file
23
exercises/task22/libFoo/foo.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#include "foo.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
#include <random>
|
||||
|
||||
namespace foo {
|
||||
|
||||
int random_number()
|
||||
{
|
||||
static std::random_device device;
|
||||
static std::mt19937 rng(device());
|
||||
static std::uniform_int_distribution<int> dist(0, std::numeric_limits<int>::max());
|
||||
|
||||
return dist(rng);
|
||||
}
|
||||
|
||||
void just_a_print()
|
||||
{
|
||||
std::cout << "Just a print to stdout, nothing else\n";
|
||||
}
|
||||
|
||||
} // end namespace foo
|
12
exercises/task22/libFoo/foo.hpp
Normal file
12
exercises/task22/libFoo/foo.hpp
Normal file
@@ -0,0 +1,12 @@
|
||||
#ifndef FOO_HPP
|
||||
#define FOO_HPP
|
||||
|
||||
namespace foo {
|
||||
|
||||
int random_number();
|
||||
|
||||
void just_a_print();
|
||||
|
||||
} // end namespace foo
|
||||
|
||||
#endif // FOO_HPP
|
Reference in New Issue
Block a user