Code consolidation and redundancy involving templates and vectors

  • (2 Pages)
  • +
  • 1
  • 2

20 Replies - 2673 Views - Last Post: 15 March 2017 - 05:49 PM Rate Topic: ***-- 2 Votes

#1 Non Sequitur  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 12-March 17

Code consolidation and redundancy involving templates and vectors

Posted 12 March 2017 - 09:27 PM

Greetings all... Below I have a sample program with the headers and cpp files listed. As you can see in the main routine, there are 5 function calls that are all very similar. They call 5 corresponding routines in the Classrooms class. Can I solicit solutions to making this one call, with variables or templates to reduce the calls, or at least have a single call with typing? The only thing I can't change is the access of the vectors in the Classrooms.h.

I've tried this with templates and to be honest damn near threw my keyboard through the monitor with frustration. Anybody can help?


Names.h

    class Names {
        public:

            enum class Enums : int { Jack, Jill, John, Judy, Jzee };
    };


Names.cpp
    #include "Names.h"


Students.h

    #include <algorithm>
    #include <condition_variable>
    #include "Names.h"

    template <Names::Enums name_a> class Students {
        public:
            Students();
            void PrintEnum();
    };

    template <Names::Enums name_a> Students<name_a>::Students() {
    }

    template <Names::Enums name_a> void Students<name_a>::PrintEnum() {
        printf("%s: Enum value for name = %d\n", __func__, (int) name_a);
    }


Students.cpp
    #include "Students.h"


Classrooms.h

    #include <algorithm>
    #include <condition_variable>
    #include "Names.h"
    #include "Students.h"

    class Classrooms {
        private:
            std::vector<std::unique_ptr<Students<Names::Enums::Jack>>> Jacks;
    
            std::vector<std::unique_ptr<Students<Names::Enums::Jill>>> Jills;
    
            std::vector<std::unique_ptr<Students<Names::Enums::John>>> Johns;
    
            std::vector<std::unique_ptr<Students<Names::Enums::Judy>>> Judys;
    
            std::vector<std::unique_ptr<Students<Names::Enums::Jzee>>> Jzees;

        public:

            Classrooms() { }
    
            Students<Names::Enums::Jack>* Get_a_Jack(int e) { return Jacks.at(e).get(); }
    
            Students<Names::Enums::Jill>* Get_a_Jill(int e) { return Jills.at(e).get(); }
    
            Students<Names::Enums::John>* Get_a_John(int e) { return Johns.at(e).get(); }
    
            Students<Names::Enums::Judy>* Get_a_Judy(int e) { return Judys.at(e).get(); }
    
            Students<Names::Enums::Jzee>* Get_a_Jzee(int e) { return Jzees.at(e).get(); }
    
    };


Classrooms.cpp
    #include "Classrooms.h"


main.cpp

    #include <algorithm>
    #include <condition_variable>
    #include "Names.h"
    #include "Classrooms.h"

    using namespace std;

    int main(int argc, char** argv) {
    
        Classrooms *cr = new Classrooms();
    
        cr->Get_a_Jack(0)->PrintEnum();
    
        cr->Get_a_Jill(0)->PrintEnum();
    
        cr->Get_a_John(0)->PrintEnum();
    
        cr->Get_a_Judy(0)->PrintEnum();
    
        cr->Get_a_Jzee(0)->PrintEnum();

        return 0;
    }


Is This A Good Question/Topic? 0
  • +

Replies To: Code consolidation and redundancy involving templates and vectors

#2 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 5899
  • View blog
  • Posts: 20,142
  • Joined: 05-May 12

Re: Code consolidation and redundancy involving templates and vectors

Posted 13 March 2017 - 05:17 AM

Wow! Talk about misusing templates. The first question I would ask is why is it important that a student named Jack is a different type from a student named Jill? Can't you simply have all students to be the same type, but each instance have different names?
Was This Post Helpful? 2
  • +
  • -

#3 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 5899
  • View blog
  • Posts: 20,142
  • Joined: 05-May 12

Re: Code consolidation and redundancy involving templates and vectors

Posted 13 March 2017 - 08:33 AM

How about something much simpler like below?
#include <map>
#include <vector>
#include <memory>

enum Suits { Clubs, Diamonds, Hearts, Spades };

class Card
{
private:
    Suits m_suit;

public:
    Card(Suits suit)
        : m_suit(suit)
    {
    }

    Suits Suit() const
    {
        return m_suit;
    }
};

class Deck
{
    std::map<Suits, std::vector<std::unique_ptr<Card>>> m_mpvecSuitCard;

public:
    std::unique_ptr<Card> DrawNthSuitCard(int index, Suits suit)
    {
        auto & vec = m_mpvecSuitCard[suit];
        auto card = std::move(vec.at(index));
        vec.erase(vec.begin() + index);
        return std::move(card);
    }

    void AddCard(std::unique_ptr<Card> card)
    {
        m_mpvecSuitCard[card->Suit()].push_back(std::move(card));
    }
};

int main()
{
    auto card = std::make_unique<Card>(Diamonds);

    Deck deck;
    deck.AddCard(std::move(card));

    auto draw = deck.DrawNthSuitCard(0, Diamonds);
    return 0;
}


Was This Post Helpful? 1
  • +
  • -

#4 Non Sequitur  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 12-March 17

Re: Code consolidation and redundancy involving templates and vectors

Posted 13 March 2017 - 10:32 AM

View PostSkydiver, on 13 March 2017 - 05:17 AM, said:

Wow! Talk about misusing templates. The first question I would ask is why is it important that a student named Jack is a different type from a student named Jill? Can't you simply have all students to be the same type, but each instance have different names?


This is ONLY a sample bit of code. It is in no way representative of the actual code, which is way to complicated and sensitive in nature to be put in a post. Not to mention I never seem to get answers, just critiques over the sample. Students, name and classrooms is not the questions. I'm simply trying to find a cleaner way of condensing the 5 separate calls from main and the corresponding calls in Classrooms so that there aren't so many individual calls. Maybe one with a switch. But I can't seem to get it done.

Thanks for the following input. Nice example, nevertheless.
Was This Post Helpful? 0
  • +
  • -

#5 jjl  Icon User is offline

  • Engineer
  • member icon

Reputation: 1270
  • View blog
  • Posts: 4,997
  • Joined: 09-June 09

Re: Code consolidation and redundancy involving templates and vectors

Posted 13 March 2017 - 11:26 AM

Ditch the enums, they simply make your code "hardcoded". Why not just represent a student with a std::string?

class Student {
   std::string name;

   public:
   Student(const std::string &name) : name(name) {}
};

class Classroom {
   public:

   Student *getStudent(const std::string &name) {
      return new Student(name);
   }
};

int main() {

   Classroom room;

   Student *john = room.getStudent("john");
   Student *mary = room.getStudent("mary");

  //etc..

}


This post has been edited by jjl: 13 March 2017 - 11:27 AM

Was This Post Helpful? 2
  • +
  • -

#6 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 5899
  • View blog
  • Posts: 20,142
  • Joined: 05-May 12

Re: Code consolidation and redundancy involving templates and vectors

Posted 13 March 2017 - 01:26 PM

Lol! Stringly-typed if the student names do matter. :) If they do not matter, then +1. This gets rid of the "hardcoding" and/or tight coupling.

Posted Image
https://blog.codingh...ramming-jargon/

Anyway, the real question for the OP is what parts of lines 22-30 of Classroom.h can be changed, and what parts cannot?
Was This Post Helpful? 1
  • +
  • -

#7 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 5899
  • View blog
  • Posts: 20,142
  • Joined: 05-May 12

Re: Code consolidation and redundancy involving templates and vectors

Posted 14 March 2017 - 08:45 AM

Assuming that the accessors can be changed and that the Jack and Jill types do matter, here's how I would approach it:
#include <map>
#include <vector>
#include <memory>

enum Suits { Clubs, Diamonds, Hearts, Spades };

class BaseCard
{
public:
    virtual Suits Suit() const = 0;
};

template<Suits suit>
class Card : public BaseCard
{
public:
    Suits Suit() const
    {
        return suit;
    }
};

class Deck
{
    std::map<Suits, std::vector<std::unique_ptr<BaseCard>>> m_mpvecSuitCard;

public:
    template<Suits suit>
    std::unique_ptr<Card<suit>> DrawNthCard(int index)
    {
        auto & vec = m_mpvecSuitCard[suit];
        auto basecard = std::move(vec.at(index));
        vec.erase(vec.begin() + index);

        BaseCard * pbasecard = basecard.release();
        Card<suit> * pcard = dynamic_cast<Card<suit> *>(pbasecard);
        return std::unique_ptr<Card<suit>>(pcard);
    }

    template<Suits suit>
    void Add(std::unique_ptr<Card<suit>> card)
    {
        m_mpvecSuitCard[suit].push_back(std::move(card));
    }
};

int main()
{
    auto card = std::make_unique<Card<Diamonds>>();

    Deck deck;
    deck.Add<Diamonds>(std::move(card));

    auto draw = deck.DrawNthCard<Diamonds>(0);
    return 0;
}



Beware that there is a bug regarding the unique pointer's deleter not being moved. If you use a custom allocator and therefore need a custom deleter, then you'll have to ensure that correct deleter is passed along with the unique pointer.

Also note that as long as you are playing the concrete classes, the compiler can deduce the template type parameter for the call to Deck::Add<T>(). No need to write Add<Diamonds>().

This post has been edited by Skydiver: 14 March 2017 - 09:10 AM
Reason for edit:: Added some notes regarding deleter and type inference.

Was This Post Helpful? 1
  • +
  • -

#8 Non Sequitur  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 12-March 17

Re: Code consolidation and redundancy involving templates and vectors

Posted 14 March 2017 - 03:53 PM

Fantastic answer...
template < Names::Enums Name >
Students<Name>* Get(int e)
{
        return std::get< std::vector<std::unique_ptr<Students<Name>>> >( std::tie( Jacks, Jills, Johns, Judys, Jzees ) ).at(e).get();
}


This post has been edited by Skydiver: 14 March 2017 - 04:14 PM
Reason for edit:: Put code in code tags. Please remember to do this.

Was This Post Helpful? 1
  • +
  • -

#9 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 5899
  • View blog
  • Posts: 20,142
  • Joined: 05-May 12

Re: Code consolidation and redundancy involving templates and vectors

Posted 15 March 2017 - 07:32 AM

Okay, after playing around with that a little bit, all it did was save having multiple accessors. You still have to have multiple vector declarations -- one for each enum type. Additionally, you have to also make sure that you don't miss any of those in the that function.
Was This Post Helpful? 1
  • +
  • -

#10 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 5899
  • View blog
  • Posts: 20,142
  • Joined: 05-May 12

Re: Code consolidation and redundancy involving templates and vectors

Posted 15 March 2017 - 09:27 AM

Non Sequitur: Could you post a completed "Classrooms.h" with that new code? I'm having trouble getting the code to compile with just your post #8.

I'm getting the following error with GCC set to use C++14 :
||=== Build: Debug in SimpleCodeBlocksCpp (compiler: GNU GCC Compiler) ===|
c:\mingw\include\c++\6.1.0\tuple||In instantiation of 'constexpr _Tp&& std::get(std::tuple<_Elements ...>&&) [with _Tp = std::vector<std::unique_ptr<Students<(Names::Enums)0> > >; _Types = {std::vector<std::unique_ptr<Students<(Names::Enums)0>, std::default_delete<Students<(Names::Enums)0> > >, std::allocator<std::unique_ptr<Students<(Names::Enums)0>, std::default_delete<Students<(Names::Enums)0> > > > >&, std::vector<std::unique_ptr<Students<(Names::Enums)1>, std::default_delete<Students<(Names::Enums)1> > >, std::allocator<std::unique_pt|
D:\z\Test\SimpleCodeBlocksCpp\main.cpp|45|required from 'Students<Name>* Classrooms::Get(int) [with Names::Enums Name = (Names::Enums)0]'|
D:\z\Test\SimpleCodeBlocksCpp\main.cpp|55|required from here|
c:\mingw\include\c++\6.1.0\tuple|1277|error: no matching function for call to '__get_helper2(std::tuple<std::vector<std::unique_ptr<Students<(Names::Enums)0>, std::default_delete<Students<(Names::Enums)0> > >, std::allocator<std::unique_ptr<Students<(Names::Enums)0>, std::default_delete<Students<(Names::Enums)0> > > > >&, std::vector<std::unique_ptr<Students<(Names::Enums)1>, std::default_delete<Students<(Names::Enums)1> > >, std::allocator<std::unique_ptr<Students<(Names::Enums)1>, std::default_delete<Students<(Names::Enums)1> > > > >&, std::|
c:\mingw\include\c++\6.1.0\tuple|1259|note: candidate: template<class _Head, long long unsigned int __i, class ... _Tail> constexpr _Head& std::__get_helper2(std::_Tuple_impl<__i, _Head, _Tail ...>&)|
c:\mingw\include\c++\6.1.0\tuple|1259|note:   template argument deduction/substitution failed:|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   mismatched types 'std::vector<std::unique_ptr<Students<(Names::Enums)0> > >' and 'std::vector<std::unique_ptr<Students<(Names::Enums)0> > >&'|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   mismatched types 'std::vector<std::unique_ptr<Students<(Names::Enums)0> > >' and 'std::vector<std::unique_ptr<Students<(Names::Enums)1> > >&'|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   mismatched types 'std::vector<std::unique_ptr<Students<(Names::Enums)0> > >' and 'std::vector<std::unique_ptr<Students<(Names::Enums)2> > >&'|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   mismatched types 'std::vector<std::unique_ptr<Students<(Names::Enums)0> > >' and 'std::vector<std::unique_ptr<Students<(Names::Enums)3> > >&'|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   mismatched types 'std::vector<std::unique_ptr<Students<(Names::Enums)0> > >' and 'std::vector<std::unique_ptr<Students<(Names::Enums)4> > >&'|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   'std::tuple<std::vector<std::unique_ptr<Students<(Names::Enums)0>, std::default_delete<Students<(Names::Enums)0> > >, std::allocator<std::unique_ptr<Students<(Names::Enums)0>, std::default_delete<Students<(Names::Enums)0> > > > >&, std::vector<std::unique_ptr<Students<(Names::Enums)1>, std::default_delete<Students<(Names::Enums)1> > >, std::allocator<std::unique_ptr<Students<(Names::Enums)1>, std::default_delete<Students<(Names::Enums)1> > > > >&, std::vector<std::unique_ptr<Students<(Names::Enums)|
c:\mingw\include\c++\6.1.0\tuple|1264|note: candidate: template<class _Head, long long unsigned int __i, class ... _Tail> constexpr const _Head& std::__get_helper2(const std::_Tuple_impl<__i, _Head, _Tail ...>&)|
c:\mingw\include\c++\6.1.0\tuple|1264|note:   template argument deduction/substitution failed:|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   mismatched types 'std::vector<std::unique_ptr<Students<(Names::Enums)0> > >' and 'std::vector<std::unique_ptr<Students<(Names::Enums)0> > >&'|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   mismatched types 'std::vector<std::unique_ptr<Students<(Names::Enums)0> > >' and 'std::vector<std::unique_ptr<Students<(Names::Enums)1> > >&'|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   mismatched types 'std::vector<std::unique_ptr<Students<(Names::Enums)0> > >' and 'std::vector<std::unique_ptr<Students<(Names::Enums)2> > >&'|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   mismatched types 'std::vector<std::unique_ptr<Students<(Names::Enums)0> > >' and 'std::vector<std::unique_ptr<Students<(Names::Enums)3> > >&'|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   mismatched types 'std::vector<std::unique_ptr<Students<(Names::Enums)0> > >' and 'std::vector<std::unique_ptr<Students<(Names::Enums)4> > >&'|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   'std::tuple<std::vector<std::unique_ptr<Students<(Names::Enums)0>, std::default_delete<Students<(Names::Enums)0> > >, std::allocator<std::unique_ptr<Students<(Names::Enums)0>, std::default_delete<Students<(Names::Enums)0> > > > >&, std::vector<std::unique_ptr<Students<(Names::Enums)1>, std::default_delete<Students<(Names::Enums)1> > >, std::allocator<std::unique_ptr<Students<(Names::Enums)1>, std::default_delete<Students<(Names::Enums)1> > > > >&, std::vector<std::unique_ptr<Students<(Names::Enums)|
c:\mingw\include\c++\6.1.0\tuple||In instantiation of 'constexpr _Tp&& std::get(std::tuple<_Elements ...>&&) [with _Tp = std::vector<std::unique_ptr<Students<(Names::Enums)1> > >; _Types = {std::vector<std::unique_ptr<Students<(Names::Enums)0>, std::default_delete<Students<(Names::Enums)0> > >, std::allocator<std::unique_ptr<Students<(Names::Enums)0>, std::default_delete<Students<(Names::Enums)0> > > > >&, std::vector<std::unique_ptr<Students<(Names::Enums)1>, std::default_delete<Students<(Names::Enums)1> > >, std::allocator<std::unique_pt|
D:\z\Test\SimpleCodeBlocksCpp\main.cpp|45|required from 'Students<Name>* Classrooms::Get(int) [with Names::Enums Name = (Names::Enums)1]'|
D:\z\Test\SimpleCodeBlocksCpp\main.cpp|57|required from here|
c:\mingw\include\c++\6.1.0\tuple|1277|error: no matching function for call to '__get_helper2(std::tuple<std::vector<std::unique_ptr<Students<(Names::Enums)0>, std::default_delete<Students<(Names::Enums)0> > >, std::allocator<std::unique_ptr<Students<(Names::Enums)0>, std::default_delete<Students<(Names::Enums)0> > > > >&, std::vector<std::unique_ptr<Students<(Names::Enums)1>, std::default_delete<Students<(Names::Enums)1> > >, std::allocator<std::unique_ptr<Students<(Names::Enums)1>, std::default_delete<Students<(Names::Enums)1> > > > >&, std::|
c:\mingw\include\c++\6.1.0\tuple|1259|note: candidate: template<class _Head, long long unsigned int __i, class ... _Tail> constexpr _Head& std::__get_helper2(std::_Tuple_impl<__i, _Head, _Tail ...>&)|
c:\mingw\include\c++\6.1.0\tuple|1259|note:   template argument deduction/substitution failed:|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   mismatched types 'std::vector<std::unique_ptr<Students<(Names::Enums)1> > >' and 'std::vector<std::unique_ptr<Students<(Names::Enums)0> > >&'|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   mismatched types 'std::vector<std::unique_ptr<Students<(Names::Enums)1> > >' and 'std::vector<std::unique_ptr<Students<(Names::Enums)1> > >&'|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   mismatched types 'std::vector<std::unique_ptr<Students<(Names::Enums)1> > >' and 'std::vector<std::unique_ptr<Students<(Names::Enums)2> > >&'|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   mismatched types 'std::vector<std::unique_ptr<Students<(Names::Enums)1> > >' and 'std::vector<std::unique_ptr<Students<(Names::Enums)3> > >&'|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   mismatched types 'std::vector<std::unique_ptr<Students<(Names::Enums)1> > >' and 'std::vector<std::unique_ptr<Students<(Names::Enums)4> > >&'|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   'std::tuple<std::vector<std::unique_ptr<Students<(Names::Enums)0>, std::default_delete<Students<(Names::Enums)0> > >, std::allocator<std::unique_ptr<Students<(Names::Enums)0>, std::default_delete<Students<(Names::Enums)0> > > > >&, std::vector<std::unique_ptr<Students<(Names::Enums)1>, std::default_delete<Students<(Names::Enums)1> > >, std::allocator<std::unique_ptr<Students<(Names::Enums)1>, std::default_delete<Students<(Names::Enums)1> > > > >&, std::vector<std::unique_ptr<Students<(Names::Enums)|
c:\mingw\include\c++\6.1.0\tuple|1264|note: candidate: template<class _Head, long long unsigned int __i, class ... _Tail> constexpr const _Head& std::__get_helper2(const std::_Tuple_impl<__i, _Head, _Tail ...>&)|
c:\mingw\include\c++\6.1.0\tuple|1264|note:   template argument deduction/substitution failed:|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   mismatched types 'std::vector<std::unique_ptr<Students<(Names::Enums)1> > >' and 'std::vector<std::unique_ptr<Students<(Names::Enums)0> > >&'|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   mismatched types 'std::vector<std::unique_ptr<Students<(Names::Enums)1> > >' and 'std::vector<std::unique_ptr<Students<(Names::Enums)1> > >&'|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   mismatched types 'std::vector<std::unique_ptr<Students<(Names::Enums)1> > >' and 'std::vector<std::unique_ptr<Students<(Names::Enums)2> > >&'|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   mismatched types 'std::vector<std::unique_ptr<Students<(Names::Enums)1> > >' and 'std::vector<std::unique_ptr<Students<(Names::Enums)3> > >&'|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   mismatched types 'std::vector<std::unique_ptr<Students<(Names::Enums)1> > >' and 'std::vector<std::unique_ptr<Students<(Names::Enums)4> > >&'|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   'std::tuple<std::vector<std::unique_ptr<Students<(Names::Enums)0>, std::default_delete<Students<(Names::Enums)0> > >, std::allocator<std::unique_ptr<Students<(Names::Enums)0>, std::default_delete<Students<(Names::Enums)0> > > > >&, std::vector<std::unique_ptr<Students<(Names::Enums)1>, std::default_delete<Students<(Names::Enums)1> > >, std::allocator<std::unique_ptr<Students<(Names::Enums)1>, std::default_delete<Students<(Names::Enums)1> > > > >&, std::vector<std::unique_ptr<Students<(Names::Enums)|
c:\mingw\include\c++\6.1.0\tuple||In instantiation of 'constexpr _Tp&& std::get(std::tuple<_Elements ...>&&) [with _Tp = std::vector<std::unique_ptr<Students<(Names::Enums)2> > >; _Types = {std::vector<std::unique_ptr<Students<(Names::Enums)0>, std::default_delete<Students<(Names::Enums)0> > >, std::allocator<std::unique_ptr<Students<(Names::Enums)0>, std::default_delete<Students<(Names::Enums)0> > > > >&, std::vector<std::unique_ptr<Students<(Names::Enums)1>, std::default_delete<Students<(Names::Enums)1> > >, std::allocator<std::unique_pt|
D:\z\Test\SimpleCodeBlocksCpp\main.cpp|45|required from 'Students<Name>* Classrooms::Get(int) [with Names::Enums Name = (Names::Enums)2]'|
D:\z\Test\SimpleCodeBlocksCpp\main.cpp|59|required from here|
c:\mingw\include\c++\6.1.0\tuple|1277|error: no matching function for call to '__get_helper2(std::tuple<std::vector<std::unique_ptr<Students<(Names::Enums)0>, std::default_delete<Students<(Names::Enums)0> > >, std::allocator<std::unique_ptr<Students<(Names::Enums)0>, std::default_delete<Students<(Names::Enums)0> > > > >&, std::vector<std::unique_ptr<Students<(Names::Enums)1>, std::default_delete<Students<(Names::Enums)1> > >, std::allocator<std::unique_ptr<Students<(Names::Enums)1>, std::default_delete<Students<(Names::Enums)1> > > > >&, std::|
c:\mingw\include\c++\6.1.0\tuple|1259|note: candidate: template<class _Head, long long unsigned int __i, class ... _Tail> constexpr _Head& std::__get_helper2(std::_Tuple_impl<__i, _Head, _Tail ...>&)|
c:\mingw\include\c++\6.1.0\tuple|1259|note:   template argument deduction/substitution failed:|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   mismatched types 'std::vector<std::unique_ptr<Students<(Names::Enums)2> > >' and 'std::vector<std::unique_ptr<Students<(Names::Enums)0> > >&'|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   mismatched types 'std::vector<std::unique_ptr<Students<(Names::Enums)2> > >' and 'std::vector<std::unique_ptr<Students<(Names::Enums)1> > >&'|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   mismatched types 'std::vector<std::unique_ptr<Students<(Names::Enums)2> > >' and 'std::vector<std::unique_ptr<Students<(Names::Enums)2> > >&'|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   mismatched types 'std::vector<std::unique_ptr<Students<(Names::Enums)2> > >' and 'std::vector<std::unique_ptr<Students<(Names::Enums)3> > >&'|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   mismatched types 'std::vector<std::unique_ptr<Students<(Names::Enums)2> > >' and 'std::vector<std::unique_ptr<Students<(Names::Enums)4> > >&'|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   'std::tuple<std::vector<std::unique_ptr<Students<(Names::Enums)0>, std::default_delete<Students<(Names::Enums)0> > >, std::allocator<std::unique_ptr<Students<(Names::Enums)0>, std::default_delete<Students<(Names::Enums)0> > > > >&, std::vector<std::unique_ptr<Students<(Names::Enums)1>, std::default_delete<Students<(Names::Enums)1> > >, std::allocator<std::unique_ptr<Students<(Names::Enums)1>, std::default_delete<Students<(Names::Enums)1> > > > >&, std::vector<std::unique_ptr<Students<(Names::Enums)|
c:\mingw\include\c++\6.1.0\tuple|1264|note: candidate: template<class _Head, long long unsigned int __i, class ... _Tail> constexpr const _Head& std::__get_helper2(const std::_Tuple_impl<__i, _Head, _Tail ...>&)|
c:\mingw\include\c++\6.1.0\tuple|1264|note:   template argument deduction/substitution failed:|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   mismatched types 'std::vector<std::unique_ptr<Students<(Names::Enums)2> > >' and 'std::vector<std::unique_ptr<Students<(Names::Enums)0> > >&'|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   mismatched types 'std::vector<std::unique_ptr<Students<(Names::Enums)2> > >' and 'std::vector<std::unique_ptr<Students<(Names::Enums)1> > >&'|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   mismatched types 'std::vector<std::unique_ptr<Students<(Names::Enums)2> > >' and 'std::vector<std::unique_ptr<Students<(Names::Enums)2> > >&'|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   mismatched types 'std::vector<std::unique_ptr<Students<(Names::Enums)2> > >' and 'std::vector<std::unique_ptr<Students<(Names::Enums)3> > >&'|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   mismatched types 'std::vector<std::unique_ptr<Students<(Names::Enums)2> > >' and 'std::vector<std::unique_ptr<Students<(Names::Enums)4> > >&'|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   'std::tuple<std::vector<std::unique_ptr<Students<(Names::Enums)0>, std::default_delete<Students<(Names::Enums)0> > >, std::allocator<std::unique_ptr<Students<(Names::Enums)0>, std::default_delete<Students<(Names::Enums)0> > > > >&, std::vector<std::unique_ptr<Students<(Names::Enums)1>, std::default_delete<Students<(Names::Enums)1> > >, std::allocator<std::unique_ptr<Students<(Names::Enums)1>, std::default_delete<Students<(Names::Enums)1> > > > >&, std::vector<std::unique_ptr<Students<(Names::Enums)|
c:\mingw\include\c++\6.1.0\tuple||In instantiation of 'constexpr _Tp&& std::get(std::tuple<_Elements ...>&&) [with _Tp = std::vector<std::unique_ptr<Students<(Names::Enums)3> > >; _Types = {std::vector<std::unique_ptr<Students<(Names::Enums)0>, std::default_delete<Students<(Names::Enums)0> > >, std::allocator<std::unique_ptr<Students<(Names::Enums)0>, std::default_delete<Students<(Names::Enums)0> > > > >&, std::vector<std::unique_ptr<Students<(Names::Enums)1>, std::default_delete<Students<(Names::Enums)1> > >, std::allocator<std::unique_pt|
D:\z\Test\SimpleCodeBlocksCpp\main.cpp|45|required from 'Students<Name>* Classrooms::Get(int) [with Names::Enums Name = (Names::Enums)3]'|
D:\z\Test\SimpleCodeBlocksCpp\main.cpp|61|required from here|
c:\mingw\include\c++\6.1.0\tuple|1277|error: no matching function for call to '__get_helper2(std::tuple<std::vector<std::unique_ptr<Students<(Names::Enums)0>, std::default_delete<Students<(Names::Enums)0> > >, std::allocator<std::unique_ptr<Students<(Names::Enums)0>, std::default_delete<Students<(Names::Enums)0> > > > >&, std::vector<std::unique_ptr<Students<(Names::Enums)1>, std::default_delete<Students<(Names::Enums)1> > >, std::allocator<std::unique_ptr<Students<(Names::Enums)1>, std::default_delete<Students<(Names::Enums)1> > > > >&, std::|
c:\mingw\include\c++\6.1.0\tuple|1259|note: candidate: template<class _Head, long long unsigned int __i, class ... _Tail> constexpr _Head& std::__get_helper2(std::_Tuple_impl<__i, _Head, _Tail ...>&)|
c:\mingw\include\c++\6.1.0\tuple|1259|note:   template argument deduction/substitution failed:|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   mismatched types 'std::vector<std::unique_ptr<Students<(Names::Enums)3> > >' and 'std::vector<std::unique_ptr<Students<(Names::Enums)0> > >&'|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   mismatched types 'std::vector<std::unique_ptr<Students<(Names::Enums)3> > >' and 'std::vector<std::unique_ptr<Students<(Names::Enums)1> > >&'|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   mismatched types 'std::vector<std::unique_ptr<Students<(Names::Enums)3> > >' and 'std::vector<std::unique_ptr<Students<(Names::Enums)2> > >&'|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   mismatched types 'std::vector<std::unique_ptr<Students<(Names::Enums)3> > >' and 'std::vector<std::unique_ptr<Students<(Names::Enums)3> > >&'|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   mismatched types 'std::vector<std::unique_ptr<Students<(Names::Enums)3> > >' and 'std::vector<std::unique_ptr<Students<(Names::Enums)4> > >&'|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   'std::tuple<std::vector<std::unique_ptr<Students<(Names::Enums)0>, std::default_delete<Students<(Names::Enums)0> > >, std::allocator<std::unique_ptr<Students<(Names::Enums)0>, std::default_delete<Students<(Names::Enums)0> > > > >&, std::vector<std::unique_ptr<Students<(Names::Enums)1>, std::default_delete<Students<(Names::Enums)1> > >, std::allocator<std::unique_ptr<Students<(Names::Enums)1>, std::default_delete<Students<(Names::Enums)1> > > > >&, std::vector<std::unique_ptr<Students<(Names::Enums)|
c:\mingw\include\c++\6.1.0\tuple|1264|note: candidate: template<class _Head, long long unsigned int __i, class ... _Tail> constexpr const _Head& std::__get_helper2(const std::_Tuple_impl<__i, _Head, _Tail ...>&)|
c:\mingw\include\c++\6.1.0\tuple|1264|note:   template argument deduction/substitution failed:|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   mismatched types 'std::vector<std::unique_ptr<Students<(Names::Enums)3> > >' and 'std::vector<std::unique_ptr<Students<(Names::Enums)0> > >&'|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   mismatched types 'std::vector<std::unique_ptr<Students<(Names::Enums)3> > >' and 'std::vector<std::unique_ptr<Students<(Names::Enums)1> > >&'|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   mismatched types 'std::vector<std::unique_ptr<Students<(Names::Enums)3> > >' and 'std::vector<std::unique_ptr<Students<(Names::Enums)2> > >&'|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   mismatched types 'std::vector<std::unique_ptr<Students<(Names::Enums)3> > >' and 'std::vector<std::unique_ptr<Students<(Names::Enums)3> > >&'|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   mismatched types 'std::vector<std::unique_ptr<Students<(Names::Enums)3> > >' and 'std::vector<std::unique_ptr<Students<(Names::Enums)4> > >&'|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   'std::tuple<std::vector<std::unique_ptr<Students<(Names::Enums)0>, std::default_delete<Students<(Names::Enums)0> > >, std::allocator<std::unique_ptr<Students<(Names::Enums)0>, std::default_delete<Students<(Names::Enums)0> > > > >&, std::vector<std::unique_ptr<Students<(Names::Enums)1>, std::default_delete<Students<(Names::Enums)1> > >, std::allocator<std::unique_ptr<Students<(Names::Enums)1>, std::default_delete<Students<(Names::Enums)1> > > > >&, std::vector<std::unique_ptr<Students<(Names::Enums)|
c:\mingw\include\c++\6.1.0\tuple||In instantiation of 'constexpr _Tp&& std::get(std::tuple<_Elements ...>&&) [with _Tp = std::vector<std::unique_ptr<Students<(Names::Enums)4> > >; _Types = {std::vector<std::unique_ptr<Students<(Names::Enums)0>, std::default_delete<Students<(Names::Enums)0> > >, std::allocator<std::unique_ptr<Students<(Names::Enums)0>, std::default_delete<Students<(Names::Enums)0> > > > >&, std::vector<std::unique_ptr<Students<(Names::Enums)1>, std::default_delete<Students<(Names::Enums)1> > >, std::allocator<std::unique_pt|
D:\z\Test\SimpleCodeBlocksCpp\main.cpp|45|required from 'Students<Name>* Classrooms::Get(int) [with Names::Enums Name = (Names::Enums)4]'|
D:\z\Test\SimpleCodeBlocksCpp\main.cpp|63|required from here|
c:\mingw\include\c++\6.1.0\tuple|1277|error: no matching function for call to '__get_helper2(std::tuple<std::vector<std::unique_ptr<Students<(Names::Enums)0>, std::default_delete<Students<(Names::Enums)0> > >, std::allocator<std::unique_ptr<Students<(Names::Enums)0>, std::default_delete<Students<(Names::Enums)0> > > > >&, std::vector<std::unique_ptr<Students<(Names::Enums)1>, std::default_delete<Students<(Names::Enums)1> > >, std::allocator<std::unique_ptr<Students<(Names::Enums)1>, std::default_delete<Students<(Names::Enums)1> > > > >&, std::|
c:\mingw\include\c++\6.1.0\tuple|1259|note: candidate: template<class _Head, long long unsigned int __i, class ... _Tail> constexpr _Head& std::__get_helper2(std::_Tuple_impl<__i, _Head, _Tail ...>&)|
c:\mingw\include\c++\6.1.0\tuple|1259|note:   template argument deduction/substitution failed:|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   mismatched types 'std::vector<std::unique_ptr<Students<(Names::Enums)4> > >' and 'std::vector<std::unique_ptr<Students<(Names::Enums)0> > >&'|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   mismatched types 'std::vector<std::unique_ptr<Students<(Names::Enums)4> > >' and 'std::vector<std::unique_ptr<Students<(Names::Enums)1> > >&'|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   mismatched types 'std::vector<std::unique_ptr<Students<(Names::Enums)4> > >' and 'std::vector<std::unique_ptr<Students<(Names::Enums)2> > >&'|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   mismatched types 'std::vector<std::unique_ptr<Students<(Names::Enums)4> > >' and 'std::vector<std::unique_ptr<Students<(Names::Enums)3> > >&'|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   mismatched types 'std::vector<std::unique_ptr<Students<(Names::Enums)4> > >' and 'std::vector<std::unique_ptr<Students<(Names::Enums)4> > >&'|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   'std::tuple<std::vector<std::unique_ptr<Students<(Names::Enums)0>, std::default_delete<Students<(Names::Enums)0> > >, std::allocator<std::unique_ptr<Students<(Names::Enums)0>, std::default_delete<Students<(Names::Enums)0> > > > >&, std::vector<std::unique_ptr<Students<(Names::Enums)1>, std::default_delete<Students<(Names::Enums)1> > >, std::allocator<std::unique_ptr<Students<(Names::Enums)1>, std::default_delete<Students<(Names::Enums)1> > > > >&, std::vector<std::unique_ptr<Students<(Names::Enums)|
c:\mingw\include\c++\6.1.0\tuple|1264|note: candidate: template<class _Head, long long unsigned int __i, class ... _Tail> constexpr const _Head& std::__get_helper2(const std::_Tuple_impl<__i, _Head, _Tail ...>&)|
c:\mingw\include\c++\6.1.0\tuple|1264|note:   template argument deduction/substitution failed:|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   mismatched types 'std::vector<std::unique_ptr<Students<(Names::Enums)4> > >' and 'std::vector<std::unique_ptr<Students<(Names::Enums)0> > >&'|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   mismatched types 'std::vector<std::unique_ptr<Students<(Names::Enums)4> > >' and 'std::vector<std::unique_ptr<Students<(Names::Enums)1> > >&'|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   mismatched types 'std::vector<std::unique_ptr<Students<(Names::Enums)4> > >' and 'std::vector<std::unique_ptr<Students<(Names::Enums)2> > >&'|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   mismatched types 'std::vector<std::unique_ptr<Students<(Names::Enums)4> > >' and 'std::vector<std::unique_ptr<Students<(Names::Enums)3> > >&'|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   mismatched types 'std::vector<std::unique_ptr<Students<(Names::Enums)4> > >' and 'std::vector<std::unique_ptr<Students<(Names::Enums)4> > >&'|
c:\mingw\include\c++\6.1.0\tuple|1277|note:   'std::tuple<std::vector<std::unique_ptr<Students<(Names::Enums)0>, std::default_delete<Students<(Names::Enums)0> > >, std::allocator<std::unique_ptr<Students<(Names::Enums)0>, std::default_delete<Students<(Names::Enums)0> > > > >&, std::vector<std::unique_ptr<Students<(Names::Enums)1>, std::default_delete<Students<(Names::Enums)1> > >, std::allocator<std::unique_ptr<Students<(Names::Enums)1>, std::default_delete<Students<(Names::Enums)1> > > > >&, std::vector<std::unique_ptr<Students<(Names::Enums)|
||=== Build failed: 5 error(s), 15 warning(s) (0 minute(s), 1 second(s)) ===|



And Visual Studio is giving me:
Severity	Code	Description	Project	File	Line	Suppression State
Error	C2039	'_Ttype': is not a member of 'std::_Tuple_element<_Ty,std::tuple<std::vector<std::unique_ptr<Students<Names::Enums::Jack>,std::default_delete<Students<Names::Enums::Jack>>>,std::allocator<std::unique_ptr<Students<Names::Enums::Jack>,std::default_delete<Students<Names::Enums::Jack>>>>> &,std::vector<std::unique_ptr<Students<Names::Enums::Jill>,std::default_delete<Students<Names::Enums::Jill>>>,std::allocator<std::unique_ptr<Students<Names::Enums::Jill>,std::default_delete<Students<Names::Enums::Jill>>>>> &,std::vector<std::unique_ptr<Students<Names::Enums::John>,std::default_delete<Students<Names::Enums::John>>>,std::allocator<std::unique_ptr<Students<Names::Enums::John>,std::default_delete<Students<Names::Enums::John>>>>> &,std::vector<std::unique_ptr<Students<Names::Enums::Judy>,std::default_delete<Students<Names::Enums::Judy>>>,std::allocator<std::unique_ptr<Students<Names::Enums::Judy>,std::default_delete<Students<Names::Enums::Judy>>>>> &,std::vector<std::unique_ptr<Students<Names::Enums::Jzee>,std::default_delete<Students<Names::Enums::Jzee>>>,std::allocator<std::unique_ptr<Students<Names::Enums::Jzee>,std::default_delete<Students<Names::Enums::Jzee>>>>> &>>'	SimpleCppConsole	c:\program files (x86)\microsoft visual studio 14.0\vc\include\tuple	932	
Error	C4430	missing type specifier - int assumed. Note: C++ does not support default-int	SimpleCppConsole	c:\program files (x86)\microsoft visual studio 14.0\vc\include\tuple	932	
Error	C2146	syntax error: missing ';' before identifier '_Ttype'	SimpleCppConsole	c:\program files (x86)\microsoft visual studio 14.0\vc\include\tuple	932	
Warning	C4091	'': ignored on left of 'int' when no variable is declared	SimpleCppConsole	c:\program files (x86)\microsoft visual studio 14.0\vc\include\tuple	932	
Error	C2228	left of '._Myfirst' must have class/struct/union	SimpleCppConsole	c:\program files (x86)\microsoft visual studio 14.0\vc\include\tuple	933	
Error	C2228	left of '._Val' must have class/struct/union	SimpleCppConsole	c:\program files (x86)\microsoft visual studio 14.0\vc\include\tuple	933	
Error	C2039	'_Ttype': is not a member of 'std::_Tuple_element<_Ty,std::tuple<std::vector<std::unique_ptr<Students<Names::Enums::Jack>,std::default_delete<Students<Names::Enums::Jack>>>,std::allocator<std::unique_ptr<Students<Names::Enums::Jack>,std::default_delete<Students<Names::Enums::Jack>>>>> &,std::vector<std::unique_ptr<Students<Names::Enums::Jill>,std::default_delete<Students<Names::Enums::Jill>>>,std::allocator<std::unique_ptr<Students<Names::Enums::Jill>,std::default_delete<Students<Names::Enums::Jill>>>>> &,std::vector<std::unique_ptr<Students<Names::Enums::John>,std::default_delete<Students<Names::Enums::John>>>,std::allocator<std::unique_ptr<Students<Names::Enums::John>,std::default_delete<Students<Names::Enums::John>>>>> &,std::vector<std::unique_ptr<Students<Names::Enums::Judy>,std::default_delete<Students<Names::Enums::Judy>>>,std::allocator<std::unique_ptr<Students<Names::Enums::Judy>,std::default_delete<Students<Names::Enums::Judy>>>>> &,std::vector<std::unique_ptr<Students<Names::Enums::Jzee>,std::default_delete<Students<Names::Enums::Jzee>>>,std::allocator<std::unique_ptr<Students<Names::Enums::Jzee>,std::default_delete<Students<Names::Enums::Jzee>>>>> &>>'	SimpleCppConsole	c:\program files (x86)\microsoft visual studio 14.0\vc\include\tuple	932	
Error	C2039	'_Ttype': is not a member of 'std::_Tuple_element<_Ty,std::tuple<std::vector<std::unique_ptr<Students<Names::Enums::Jack>,std::default_delete<Students<Names::Enums::Jack>>>,std::allocator<std::unique_ptr<Students<Names::Enums::Jack>,std::default_delete<Students<Names::Enums::Jack>>>>> &,std::vector<std::unique_ptr<Students<Names::Enums::Jill>,std::default_delete<Students<Names::Enums::Jill>>>,std::allocator<std::unique_ptr<Students<Names::Enums::Jill>,std::default_delete<Students<Names::Enums::Jill>>>>> &,std::vector<std::unique_ptr<Students<Names::Enums::John>,std::default_delete<Students<Names::Enums::John>>>,std::allocator<std::unique_ptr<Students<Names::Enums::John>,std::default_delete<Students<Names::Enums::John>>>>> &,std::vector<std::unique_ptr<Students<Names::Enums::Judy>,std::default_delete<Students<Names::Enums::Judy>>>,std::allocator<std::unique_ptr<Students<Names::Enums::Judy>,std::default_delete<Students<Names::Enums::Judy>>>>> &,std::vector<std::unique_ptr<Students<Names::Enums::Jzee>,std::default_delete<Students<Names::Enums::Jzee>>>,std::allocator<std::unique_ptr<Students<Names::Enums::Jzee>,std::default_delete<Students<Names::Enums::Jzee>>>>> &>>'	SimpleCppConsole	c:\program files (x86)\microsoft visual studio 14.0\vc\include\tuple	932	
Error	C2039	'_Ttype': is not a member of 'std::_Tuple_element<_Ty,std::tuple<std::vector<std::unique_ptr<Students<Names::Enums::Jack>,std::default_delete<Students<Names::Enums::Jack>>>,std::allocator<std::unique_ptr<Students<Names::Enums::Jack>,std::default_delete<Students<Names::Enums::Jack>>>>> &,std::vector<std::unique_ptr<Students<Names::Enums::Jill>,std::default_delete<Students<Names::Enums::Jill>>>,std::allocator<std::unique_ptr<Students<Names::Enums::Jill>,std::default_delete<Students<Names::Enums::Jill>>>>> &,std::vector<std::unique_ptr<Students<Names::Enums::John>,std::default_delete<Students<Names::Enums::John>>>,std::allocator<std::unique_ptr<Students<Names::Enums::John>,std::default_delete<Students<Names::Enums::John>>>>> &,std::vector<std::unique_ptr<Students<Names::Enums::Judy>,std::default_delete<Students<Names::Enums::Judy>>>,std::allocator<std::unique_ptr<Students<Names::Enums::Judy>,std::default_delete<Students<Names::Enums::Judy>>>>> &,std::vector<std::unique_ptr<Students<Names::Enums::Jzee>,std::default_delete<Students<Names::Enums::Jzee>>>,std::allocator<std::unique_ptr<Students<Names::Enums::Jzee>,std::default_delete<Students<Names::Enums::Jzee>>>>> &>>'	SimpleCppConsole	c:\program files (x86)\microsoft visual studio 14.0\vc\include\tuple	932	
Error	C2039	'_Ttype': is not a member of 'std::_Tuple_element<_Ty,std::tuple<std::vector<std::unique_ptr<Students<Names::Enums::Jack>,std::default_delete<Students<Names::Enums::Jack>>>,std::allocator<std::unique_ptr<Students<Names::Enums::Jack>,std::default_delete<Students<Names::Enums::Jack>>>>> &,std::vector<std::unique_ptr<Students<Names::Enums::Jill>,std::default_delete<Students<Names::Enums::Jill>>>,std::allocator<std::unique_ptr<Students<Names::Enums::Jill>,std::default_delete<Students<Names::Enums::Jill>>>>> &,std::vector<std::unique_ptr<Students<Names::Enums::John>,std::default_delete<Students<Names::Enums::John>>>,std::allocator<std::unique_ptr<Students<Names::Enums::John>,std::default_delete<Students<Names::Enums::John>>>>> &,std::vector<std::unique_ptr<Students<Names::Enums::Judy>,std::default_delete<Students<Names::Enums::Judy>>>,std::allocator<std::unique_ptr<Students<Names::Enums::Judy>,std::default_delete<Students<Names::Enums::Judy>>>>> &,std::vector<std::unique_ptr<Students<Names::Enums::Jzee>,std::default_delete<Students<Names::Enums::Jzee>>>,std::allocator<std::unique_ptr<Students<Names::Enums::Jzee>,std::default_delete<Students<Names::Enums::Jzee>>>>> &>>'	SimpleCppConsole	c:\program files (x86)\microsoft visual studio 14.0\vc\include\tuple	932	


Was This Post Helpful? 1
  • +
  • -

#11 #define  Icon User is offline

  • Duke of Err
  • member icon

Reputation: 1852
  • View blog
  • Posts: 6,661
  • Joined: 19-February 09

Re: Code consolidation and redundancy involving templates and vectors

Posted 15 March 2017 - 01:34 PM

superbonzo on codeguru.com gave the answer, that Non Sequitur likes, and a correction, if it helps.

Code Consolidation And Redundancy Involving Templates And Vectors
Was This Post Helpful? 2
  • +
  • -

#12 Non Sequitur  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 12-March 17

Re: Code consolidation and redundancy involving templates and vectors

Posted 15 March 2017 - 02:21 PM

View PostSkydiver, on 15 March 2017 - 07:32 AM, said:

Okay, after playing around with that a little bit, all it did was save having multiple accessors. You still have to have multiple vector declarations -- one for each enum type. Additionally, you have to also make sure that you don't miss any of those in the that function.


I never said I was trying to get rid of multiple vectors, simply a way to consolidate the calls an clean it up a bit. And Superbonzo's answer certainly did that. The problem with many of these sites is that the people answering usually vector off into criticisms of variable names, coding style and other things not relevant to the stated problem. Some people on the other, read the stated problem, maybe ask for clarifications and set about find an answer. And those people I respect and pay for their time. The harder the problem and more elegant solution the more money I send them via PayPal.
Was This Post Helpful? -1
  • +
  • -

#13 Non Sequitur  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 12-March 17

Re: Code consolidation and redundancy involving templates and vectors

Posted 15 March 2017 - 02:31 PM

I refer specifically to the following... "Wow! Talk about misusing templates. The first question I would ask is why is it important that a student named Jack is a different type from a student named Jill?" Not helpful.

This post has been edited by Skydiver: 15 March 2017 - 05:23 PM
Reason for edit:: Removed unnecessary quote. No need to quote the post above yours.

Was This Post Helpful? 0
  • +
  • -

#14 jjl  Icon User is offline

  • Engineer
  • member icon

Reputation: 1270
  • View blog
  • Posts: 4,997
  • Joined: 09-June 09

Re: Code consolidation and redundancy involving templates and vectors

Posted 15 March 2017 - 04:21 PM

Why is it important that a student named Jack is a different type from a student named Jill?

I guarantee that you could solve this problem using polymorphism rather banging on templates.

This post has been edited by Skydiver: 15 March 2017 - 05:24 PM
Reason for edit:: Removed unnecessary quote. No need to quote the post above yours.

Was This Post Helpful? 1
  • +
  • -

#15 Non Sequitur  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 12-March 17

Re: Code consolidation and redundancy involving templates and vectors

Posted 15 March 2017 - 04:35 PM

It doesn't matter, its a sample piece pf code, as I've stated several times. It's the best I could do to create an example. The names don't matter at all. And maybe you could do it with polymorphism. But once again, you're not focusing on my question, rather than picking apart the example. The actual code and its function is too sensitive to put on an Internet post. In any case, I got what I needed and it works fine. The documentation is clear.

This post has been edited by Skydiver: 15 March 2017 - 05:25 PM
Reason for edit:: Removed unnecessary quote. No need to quote the post above yours.

Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2