Subscribe to this list via RSS Blog posts tagged in C++11
An Overview of Elements of Functional Programming in C++ (continuation) Part II.  Where it is told about closures and "functional containers" - data structures that can store pointers to functional objects of various types std::function While the functional paradigm proclaims that "everything is a function," in imperative programming we sometimes encounter the need to manipulate functions like with ordinary objects. Usually this happens by creating a pointer to the address of the procedure or method. However, in this case and others, high-level language...
An Overview of Elements of Functional Programming in C++ Hello everybody! This article is a brief introduction to the functional programming style when using an imperative language like C++. In particular, we will use C++Builder, a C++ development environment that can target many platforms, to show examples for how functional programming can work. I'll start with some arguments about the role of functional programming in the object-oriented paradigm. Many of the statements here are controversial, so do not forget that "in a dispute, truth is born"....

Posted by on in Programming
In C++Builder(C++11), use timed_mutex. In C++11, mutex is attached as a standard library.Of course, it can also be used in C++Builder. There are mutex,recursive_mutex,timed_mutex,recursive_timed_mutex.I tried timed_mutex this time.timed_mutex supports lock acquisition timeout function.Timeout uses chrono. _tmnutex_test.h struct _tmnutex_test { std::timed_mutex f_mutex_; std::vector<String> f_v1_; void add(String str1_) { //Wait 3 seconds. if (!f_mutex_.try_lock_for(std::chrono::seco...
std::vector<T> custom allocator[JAPAN] 毛利です。   C++Builder 10.2 Tokyo (Win64)を使って、 std::allocator<T>で 自分用のallocatorを作りstd::vector<T>などで利用する事ができます。 あまり知られていませんが std::vectorを見ると template<class _Ty, class _Alloc = allocator<_Ty> >class vector{...}こうなっています。 第2引数を何も指定してなければstd::allocator<T>です。   まず、std::allocator<T>を継承したクラスを作成します。 //--------------------------------------------------------------------------- #include <functional> template <typename T> struct _Allocator: public std::allocator<T> { std::function<void...
Visual C++2017で作ったDLLをC++Builderで使う[JAPAN] 毛利です。   Visual C++で作った64BitのDLLをC++Builderで試してみました。 まずVC++2017側のコードです。 ・・・・ extern "C" CONSOLEAPPLICATION1_API int test1(int i1) { ///This function only increments. ++i1; return i1; } extern "C" CONSOLEAPPLICATION1_API void test2(int i1, wchar_t* a) { ///Convert from int to wstring. std::wstring s{}; s = std::to_wstring(i1); ///It is not valid to allocate the wchar_t in the Visual C++ DLL and then free it in C++ Builder. ///wchar_t *a = new wchar_t[s.length() + 1]; wcscpy(a, s.c_str()); ///Finally cast to wchar_t* and return. ///return a; }   ビルドするとDLLが作られます。(ConsoleApplication1.dll)  
ファイルを圧縮して保存と呼び出し方法TZCompressionStream, TZDecompressionStream[JAPAN] 毛利です。 TZCompressionStreamを使って、TStreamデータを圧縮し保存し さらにTZDecompressionStreamを使い解凍する方法をご紹介します。 まず圧縮と解凍用に共通のテンプレートクラスを作成します。 #include <fmx.h> #include <System.ZLib.hpp> #include <memory> //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } template <typename T1, typename T2, typename T3> struct compression_stream { ///Template for common. std::unique_ptr<T1> f_compression_stream; T3 f_level; T2* f_stream; compression_stream(T3 l_level, T2* l_stream) { f_level = l_level; f_stream = l_stream; f_compression_stream = {std::make_unique<T1>(l_level, f_stream)}; } compression_stream(T2* l_stream) { f_stream = l_stream; f_compression_stream = {std::make_unique<T1>(f_stream)}; } ~compression_stream() { } };
Compress and save the file. TZCompressionStream, TZDecompressionStream TZCompressionStream can compress TStream. Use TZDecompressionStream to decompress. I tried a simple code. First create a common template class. #include <fmx.h> #include <System.ZLib.hpp> #include <memory> template <typename T1, typename T2, typename T3> struct compression_stream { ///Template for common. std::unique_ptr<T1> f_compression_stream; T3 f_level; T2* f_stream; compression_stream(T3 l_level, T2* l_stream) { f_level = l_level; f_stream = l_stream; f_compression_stream = {std::make_unique<T1>(l_level, f_stream)}; } compression_stream(T2* l_stream) { f_stream = l_stream; f_compression_stream = {std::make_unique<T1>(f_stream)}; } ~compression_stream() { } };  
【C++Builder Starter チュートリアルシリーズ】シーズン2 第9回 ‟作ってみよう„ [JAPAN] 2017年1月23日より 「Delphi / C++Builder Starter チュートリアルシリーズ」 シーズン2、全9回、3月27日まで、毎週月曜日、Delphiパートが 17時00分~17時20分、 リアルタイム放送スペシャルコンテンツが5分~10分、C++Builderパートは 17時30分~17時50分の時間割でお送りしています。(なお、後述いたしますが、残り2週分の放送はDelphi/C++Builderの2部制ではありません) 無料でダウンロード&利用できる開発環境のDelphi / C++Builder Starter エディションを使用して、プログラミング言語のDelphi (Object Pascal ), C++の基礎を学ぶオンラインセッションです。 https://community.embarcadero.com/blogs/entry/2-japan
Use std::chrono(Time control) in C++Builder It can be used by library std::chrono from C++11. std::chrono can control time_point. Let's first make time_point. //// //Put the current time in time_point. using namespace std::chrono; system_clock::time_point tp = system_clock::now(); The current time(now) has entered the variable tp. It is possible to add time lapse etc. to this time_point. Use std::chrono::duration for time_point to add time.
C++ Coding Bootcamp Training Course With Over 10 Hours Of FREE Training For Android And iOS The C++ Boot Camp series is a free Coding Bootcamp training course with over 10 hours of C++ training, question & answer sessions, and much more! C++ can be used to build cross platform applications for Android, iOS, macOS, and Windows. The Android support uses the Android NDK. This coding boot camp coarse will bring you up to speed on building mobile and desktop apps quickly. You will be introduced to the C++Builder IDE, the FireMonkey UI which is powered by OpenGL, using animations and eff...

Check out more tips and tricks in this development video: