Skip to content

Tag Archives: C++-Templates

Prerequisite: Templates in C++ Generally, a C++ template, with a single argument looks like this: template<typename template_name> But it has been seen that a template… Read More
Given a Set of integers sett and an integer index, the task is to find the element in the set which is present at index.… Read More
The std::is_trivially_copy_constructible template is a type that can be trivially constructed from a value or reference of the same type. This includes scalar types, trivially… Read More
The std::is_floating_point template of C++ STL is used to check whether the given type is a floating point value or not. It returns a boolean… Read More
The std::is_object template of C++ STL is used to check whether the given type is object or not. It returns a boolean value showing the… Read More
The std::is_enum template of C++ STL is used to check whether the given type is enum or not. It returns a boolean value showing the… Read More
This template in C++ is used to convert the value generated by g into a floating point value in the range [0, 1) preserving the… Read More
Given a program that uses an iterator, the task is to find the type of iterator used. Examples: Input : vector.begin() Output : Random_Access Iterator… Read More
Output? #include <iostream> using namespace std;     template<int n> struct funStruct {     static const int val = 2*funStruct<n-1>::val; };     template<> struct funStruct<0> {     static… Read More
Output? #include <iostream> using namespace std;    template <class T> T max (T &a, T &b) {     return (a > b)? a : b; }… Read More
Output? #include <iostream> using namespace std;    template <int i> void fun() {    i = 20;    cout << i; }    int main() {    fun<10>();… Read More
Output of following program. #include <iostream> using namespace std;    template <class T, int max> int arrMin(T arr[], int n) {    int m = max;… Read More
Output of following program? Assume that the size of int is 4 bytes and size of double is 8 bytes, and there is no alignment… Read More
Output of following program? Assume that the size of char is 1 byte and size of int is 4 bytes, and there is no alignment… Read More
Output of following program? #include <iostream> using namespace std;    template <class T> class Test { private:     T val; public:     static int count;     Test()  {  … Read More