I had to make some adjustments in the source file. The adjusted source file is as follows:
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
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
Turn vector_c<int,1,2,3> into a type sequence with elements (2,3,4) using transform.
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
Exercise: Use BOOST_STATIC_ASSERT to add error checking to the binary template presented in section 1.4.1 so that binary<N>::value causes a compilation error if N contains digits other than 0 or 1.
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
This is a demonstration of addition of physical quantities using dimensional analysis:
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
Equating two physical quantities can only be done if both of them have the same dimensions. For example, a length variable can be equated to another length variable as both of them have the same dimensions (e.g., meters). It is not possible, however, to equate two physical quantities of different dimensions. For example, a mass variable cannot equated to a length variable:
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
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
In LTE, there's this thing called full configuration. I guess it's usually used in handovers. During a handover, the source eNodeB informs the target eNodeB about the source eNodeB's enabled features. For instance, the source eNodeB may inform the target eNodeB that it was performing 256QAM with the UE.
Sometimes, however, the target eNodeB does not support the features the source eNodeB was using with the UE. For instance, the source eNodeB may have been previously using 256QAM with the UE, but the target eNodeB may not have support for this feature. When this happens, the target eNodeB may issue a full configuration to the UE. It does this by sending an RRC Connection Reconfiguration message to the UE. This message is first sent to the source eNodeB, then passed as is (without modification) to the UE.
The target eNodeB informs the UE that a full configuration is in progress by sending the fullConfig-r9 information element. During full configuration, the target eNodeB has to resend all information related to bearer setup (as if these bearers were being set up from scratch or for the first time).
In the case of DRB bearers, the DRB-ToAddMod message has to have the following elements present during full configuration:
eps-BearerIdentity
pdcp-Config
discardTimer
rlc-AM or rlc-UM (one of them, but not both, has to be present)
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
Notice how searching for a key is recursive. When a key is not found in s, it is searched in SpecialAccount. When the key is not found in SpecialAccount, it is searched in Account.
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
To compile and run Google Test and Google Mock in Ubuntu, you can follow these steps.
First download Google Test from here. Extract the downloaded zip file to a directory of your choice.
After extraction, you will see a folder named googletest-master. Enter this folder.
Inside the googletest-master folder, you will see these two folders: googletest and googlemock.
To compile and test run google test, go to the googletest directory. There you will see a make directory. Go inside the make directory and type 'make'.
Executing the make command will create the executable file, sample1_unittest. You can then run this executable file: kuyu@castor-ub:~/dkuyu/bin/googletest-master/googletest/make$ pwd; ls /home/kuyu/dkuyu/bin/googletest-master/googletest/make Makefile kuyu@castor-ub:~/dkuyu/bin/googletest-master/googletest/make$ make && ./sample1_unittest g++ -isystem ../include -g -Wall -Wextra -pthread -c ../samples/sample1.cc g++ -isystem ../include -g -Wall -Wextra -pthread -c ../samples/sample1_unittest.cc g++ -isystem ../include -I.. -g -Wall -Wextra -pthread -c \ ../src/gtest-all.cc g++ -isystem ../include -I.. -g -Wall -Wextra -pthread -c \ ../src/gtest_main.cc ar rv gtest_main.a gtest-all.o gtest_main.o ar: creating gtest_main.a a - gtest-all.o a - gtest_main.o g++ -isystem ../include -g -Wall -Wextra -pthread -lpthread sample1.o sample1_unittest.o gtest_main.a -o sample1_unittest Running main() from gtest_main.cc [==========] Running 6 tests from 2 test cases. [----------] Global test environment set-up. [----------] 3 tests from FactorialTest [ RUN ] FactorialTest.Negative [ OK ] FactorialTest.Negative (0 ms) [ RUN ] FactorialTest.Zero [ OK ] FactorialTest.Zero (0 ms) [ RUN ] FactorialTest.Positive [ OK ] FactorialTest.Positive (0 ms) [----------] 3 tests from FactorialTest (0 ms total) [----------] 3 tests from IsPrimeTest [ RUN ] IsPrimeTest.Negative [ OK ] IsPrimeTest.Negative (0 ms) [ RUN ] IsPrimeTest.Trivial [ OK ] IsPrimeTest.Trivial (0 ms) [ RUN ] IsPrimeTest.Positive [ OK ] IsPrimeTest.Positive (0 ms) [----------] 3 tests from IsPrimeTest (0 ms total) [----------] Global test environment tear-down [==========] 6 tests from 2 test cases ran. (0 ms total) [ PASSED ] 6 tests. kuyu@castor-ub:~/dkuyu/bin/googletest-master/googletest/make$
You can follow similar steps to compile and test run Google Mock in Ubuntu. From the googletest-master directory, go to the googlemock/make directory. Then type make. The executable created by the make command is named gmock_test.
You can actually study the Makefile file in the googletest/make and googlemock/make directories. There you can edit the GTEST_DIR, USER_DIR, and GMOCK_DIR (for googlemock).
This is an example CppUMock test. It consists of 3 files: test_main.cpp, test.cpp and makefile.
test_main.cpp:
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
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
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
I spent several hours figuring out how to run cpputest in Ubuntu. I searched several websites, but they were not helpful. You can imagine the agony that I went through.
Finally, I came across this stackoverflow question. Thank you, pradeep (the author of the question (and also the answer)).
Well, first you need to install CppUTest in Ubuntu:
% sudo apt-get install cpputest
After that, create the files: test.cpp, test_main.cpp, and makefile
For the makefile file, be sure to use tab indentations and not spaces.
After creating the files:
kuyu@castor-ub:~/dkuyu/practice/cpp/cpputest/hello$ make g++ -g -I/usr/local/include -c test_main.cpp g++ -g -I/usr/local/include -c test.cpp g++ -g -o mytest test.o test_main.o -L/usr/local/lib -lCppUTest -lCppUTestExt kuyu@castor-ub:~/dkuyu/practice/cpp/cpputest/hello$ ./mytest test.cpp:15: error: Failure in TEST(FirstTestGroup, SecondTest) expected <hello> but was <world> difference starts at position 0 at: < world > ^ . test.cpp:10: error: Failure in TEST(FirstTestGroup, FirstTest) Fail me! . Errors (2 failures, 2 tests, 2 ran, 1 checks, 0 ignored, 0 filtered out, 1 ms) kuyu@castor-ub:~/dkuyu/practice/cpp/cpputest/hello$
Here is an example of iterator swapping for the vector<bool> proxy class:
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
Abraham, David; Gurtovoy, Aleksey. 2004. C++ template metaprogramming: Concepts, tools, and techniques from Boost and beyond. Addison Wesley.
Tried to code a little on iterator_traits:
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
kuyu@castor-ub:~/dkuyu/practice/cpp/iterator_traits$ g++ iterator_traits.cpp && ./a.out Before: a = a b = b After: a = b b = a kuyu@castor-ub:~/dkuyu/practice/cpp/iterator_traits$
Example of boost::fusion vector. It is like a C++ tuple.
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
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
Here is a code that demonstrates lambda capture by value vs reference:
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
When line 10 is used instead of line 9, running this code yields 10 instead of 4.
Ideally, 4 should be returned as the remainder of 10 divided by 6. If line 10 is used, however, the lambda function created encloses a reference to the variable x which goes out of scope as soon as the function add_func() completes execution.
After add_func() is called, the lambda function stored inside the vector uses a reference to x which is no longer valid (x only exists while add_func() is being executed). Therefore, the lambda function uses a reference to a variable with undefined value. Calling the lambda function therefore will yield to undefined results.
Here is an example implementation of factorial via template metaprogramming:
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
Got this from the book "Effective modern C++" by Scott Meyers (2014).
The book recommends the use of auto instead of explicit types. He does warn against using auto when proxy classes are involved. One example is std::vector<bool>. Using the operator[] on a std::vector<bool> yields a std::vector<bool>::reference (a proxy class) instead of a simple bool.
Consider this example:
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
According to Meyers, std::vector<bool>::reference is a class (a proxy class) that contains a pointer to a word (probably a 32-bit or 64-bit memory location) that contains the boolean value. The class also contains the offset within the word to be able to locate the boolean value.
So in the example, in line 22, b is of type std::vector<bool>::reference which contains a pointer to some memory location. Note, however, that features() returns a temporary std::vector<bool> which goes out of scope as soon as line 22 finishes execution. Thus, after line 22 is executed, the word (memory location) which contains the boolean goes out of scope. The pointer within b then becomes a dangling pointer pointing to who knows what.
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
In LTE, downlink 256QAM is triggered by a handshake between the UE and the eNodeB. First the UE signifies it is capable of performing 256QAM by sending the RRC information element (IE) dl-256QAM-r12 to the eNodeB. Should the eNodeB choose to perform 256QAM, then it sends the RRC IE altCQI-Table-r12 to the UE.
altCQI-Table-r12 is sent through the RRC message CQI-ReportConfig-r1250 which is a "Need ON" optional message. "Need ON" means that no action should be done by the UE if the UE does not receive the message again, upon say, RRC reconfiguration.
So to trigger 256QAM in the downlink, first, the UE sends dl-256QAM-r12 to the eNB to signify it is capable of 256QAM. Then the eNodeB sends CQI-ReportConfig-r1250 containing altCQI-Table-12 to the UE.
In case of RRC reconfiguration, say during handover, and the eNodeB still desires to continue using 256QAM, then it need not send CQI-ReportConfig-r1250 anymore to the UE because of the "Need ON" condition. Remember "Need ON" means that if the IE is not sent again (during reconfiguration), then the UE should maintain the status quo: if it was previously configured to use 256QAM, then after reconfiguration, it should still use 256QAM.
If the UE was previously configured by the eNodeB to use 256QAM, and after reconfiguration, the eNB does not wish to continue to use 256QAM anymore, then the eNodeB has to send CQI-ReportConfig-r1250 with no altCQI-Table-r12. The eNodeB has to send CQI-ReportConfig-r1250 with altCQI-Table-r12 missing or absent, in order to turn off 256QAM. If it does not send CQI-ReportConfig-r1250, then it means that the eNodeB still wishes to continue using 256QAM (remember "Need ON").
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