initial commit, let's just do this instead of studying. also hail Bjarne

This commit is contained in:
Kjistóf 2016-11-27 13:55:32 +01:00
commit 4427596609
4 changed files with 56 additions and 0 deletions

10
.gitignore vendored Normal file
View File

@ -0,0 +1,10 @@
.idea
.DS_Store
*.out
CMakeFiles
CMakeCache.txt
cmake_install.cmake
Makefile
Function
build
cmake-build-debug

8
CMakeLists.txt Normal file
View File

@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.6)
project(Function)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic")
set(SOURCE_FILES main.cpp)
add_executable(Function ${SOURCE_FILES})

9
Function.hpp Normal file
View File

@ -0,0 +1,9 @@
template <typename Fun>
class Function;
template <typename Ret, typename... Args>
class function
{
// TODO: everything :'D
};

29
main.cpp Normal file
View File

@ -0,0 +1,29 @@
#include <iostream>
#include <cmath>
#include "Function.hpp"
int main()
{
Function<double(double)> f;
if (!f)
std::cout << "Egyelőre nullptr" << std::endl;
f = sin;
std::cout << sin(2.3) << "==" << f(2.3) << std::endl;
f = [] (double x) { return x*x; };
std::cout << 2.3*2.3 << "==" << f(2.3) << std::endl;
f = std::bind(pow, std::placeholders::_1, 4);
std::cout << pow(2.3, 4) << "==" << f(2.3) << std::endl;
f = nullptr;
try {
f(2.3);
} catch (std::bad_function_call &e) {
std::cout << "Megint nullptr" << std::endl;
}
}