Compare commits
No commits in common. "659e010a7093d501c36f51bc2781151e6593d581" and "68da0a4b6c723da0cb6f25a09a07906a4191291e" have entirely different histories.
659e010a70
...
68da0a4b6c
|
@ -1,21 +0,0 @@
|
||||||
cmake_minimum_required(VERSION 3.20)
|
|
||||||
|
|
||||||
project(
|
|
||||||
Functor
|
|
||||||
VERSION 0.1.0
|
|
||||||
LANGUAGES CXX)
|
|
||||||
|
|
||||||
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/../cmake")
|
|
||||||
|
|
||||||
include(ExportCompileCommands)
|
|
||||||
include(sccache)
|
|
||||||
|
|
||||||
add_executable(Functor main.cpp)
|
|
||||||
|
|
||||||
target_compile_features(Functor PUBLIC cxx_std_20)
|
|
||||||
|
|
||||||
set_target_properties(
|
|
||||||
Functor
|
|
||||||
PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/bin"
|
|
||||||
RUNTIME_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/bin"
|
|
||||||
RUNTIME_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/bin")
|
|
|
@ -1 +0,0 @@
|
||||||
../scripts/bootstrap.sh
|
|
|
@ -1 +0,0 @@
|
||||||
../scripts/build.sh
|
|
|
@ -1,39 +0,0 @@
|
||||||
#include <iostream>
|
|
||||||
#include <numeric>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
class join_strings_functor {
|
|
||||||
private:
|
|
||||||
std::string separator_ = " ";
|
|
||||||
|
|
||||||
public:
|
|
||||||
join_strings_functor() = default;
|
|
||||||
join_strings_functor(std::string_view separator) : separator_(separator) {}
|
|
||||||
|
|
||||||
std::string operator()(const std::string &left,
|
|
||||||
const std::string &right) const {
|
|
||||||
return left + separator_ + right;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
|
||||||
|
|
||||||
std::cout << "Functor" << std::endl;
|
|
||||||
|
|
||||||
std::vector<std::string> names = {"Albert", "Bernd", "Cora",
|
|
||||||
"Dave", "Emil", "Frank"};
|
|
||||||
|
|
||||||
auto space_joined_string =
|
|
||||||
std::accumulate(std::next(names.begin()), names.end(), names.front(),
|
|
||||||
join_strings_functor());
|
|
||||||
|
|
||||||
std::cout << "Space-joined string: " << space_joined_string << std::endl;
|
|
||||||
|
|
||||||
auto comma_joined_string =
|
|
||||||
std::accumulate(std::next(names.begin()), names.end(), names.front(),
|
|
||||||
join_strings_functor(", "));
|
|
||||||
|
|
||||||
std::cout << "Comma-joined string: " << comma_joined_string << std::endl;
|
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
|
||||||
}
|
|
Loading…
Reference in New Issue