About function declarations in functions

We can have function declarations inside of function bodies: void f(double) { cout << "f(double) called"; } void f(int) { cout << "f(int) called"; } void g() { void f(double); //Functions declared in non-namespace scopes do not overload f(1); //Therefore, f(1) will call f(double) } This can be done in order to hide a function… Read More About function declarations in functions

when passing std::allocator<type>::pointer to my own wrap_iter i'm getting **type instead of *type

I’m trying to create a vector class and my own wrap_iter class here is my vector.hpp #ifndef VECTOR_HPP #define VECTOR_HPP namespace ft { template <class _Iter> struct iterator_traits { }; template <class T> struct iterator_traits<T*> { typedef T* pointer; }; template <class T> class wrap_iter { public: typedef T iter_type; typedef typename ft::iterator_traits<iter_type>::pointer pointer; private:… Read More when passing std::allocator<type>::pointer to my own wrap_iter i'm getting **type instead of *type

Running into "error: […] is a c++ extension"

After running: g++ –std=c++11 -ansi -pedantic-errors -Wall -o test_database test_database.cpp I am receiving the following errors: ./database.h:40:10: error: ‘auto’ type specifier is a C++11 extension [-Werror,-Wc++11-extensions] for (auto x:composerMap_) { ^ ./database.h:40:16: error: range-based for loop is a C++11 extension [-Werror,-Wc++11-extensions] for (auto x:composerMap_) { Yet note that I have already added the ‘–std=c++11’ flag… Read More Running into "error: […] is a c++ extension"

c++ passing a pointer to a template function as template

I have this iter function that takes a pointer to value_type, a size_type, and a function pointer fun_type that is supposed to take a value_type& as parameter: template < class value_type, class size_type, class fun_type > void iter(value_type *arr, size_type size, fun_type function) { while (size–) function(arr[size]); } It works fine until we have a… Read More c++ passing a pointer to a template function as template