This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import std.core; // C++ standart kütüphane çekirdeğini içe aktar | |
#include <iostream> | |
int main() { | |
std::cout << "Hello, Modules!" << std::endl; | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import MathModule; | |
#include <iostream> | |
int main() { | |
std::cout << "Multiply: " << multiply(3, 4) << std::endl; // 12 | |
std::cout << "Divide: " << divide(10, 2) << std::endl; // 5.0 | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module MathModule; | |
int multiply(int a, int b) { | |
return a * b; | |
} | |
double divide(double a, double b) { | |
if (b == 0) { | |
throw std::invalid_argument("Division by zero!"); | |
} | |
return a / b; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export module MathModule; // modül tanımı | |
export int multiply(int a, int b); // modüle export edilecek fonksiyonlar | |
export double divide(double a, double b); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import MyModule; // Modülü içe aktar | |
#include <iostream> | |
int main() { | |
std::cout << add(3, 4) << std::endl; // 7 | |
// subtract(3, 4); // Hata: subtract dışa açık değil | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export module MyModule; // Modül bildirimi | |
export int add(int a, int b) { // Export ile dışa açıyoruz | |
return a + b; | |
} | |
int subtract(int a, int b) { // Export olmadan yazılan fonksiyonlar yalnızca modül içerisinde kullanılabilir | |
return a - b; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <future> | |
#include <coroutine> | |
std::future<void> asyncPrint(int value) { | |
std::cout << "İşleniyor: " << value << std::endl; | |
co_await std::suspend_always{}; | |
std::cout << "Tamamlandı: " << value << std::endl; | |
} | |
int main() { | |
auto result = asyncPrint(42); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <coroutine> | |
struct Generator { | |
struct promise_type { | |
int current_value; | |
Generator get_return_object() { | |
return Generator{std::coroutine_handle<promise_type>::from_promise(*this)}; | |
} | |
std::suspend_always initial_suspend() { return {}; } | |
std::suspend_always final_suspend() noexcept { return {}; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <concepts> | |
#include <iostream> | |
template <typename T> | |
concept Addable = requires(T a, T b) { | |
a + b; | |
}; | |
void addAndPrint(Addable auto a, Addable auto b) { | |
std::cout << a + b << std::endl; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <typename T> | |
concept Addable = requires(T a, T b) { | |
a + b; // T türü toplama işlemini desteklemeli | |
}; |
NewerOlder