Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8901637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:24:33+00:00 2026-06-15T01:24:33+00:00

Given the following class template <typename T> class Plane { public: Plane<T>(T A, T

  • 0

Given the following class

template <typename T>
class Plane
{
public:
    Plane<T>(T A, T B, T C, const Vector3<T>& vec):
        A(A),
        B(B),
        C(C),
        D(-1*A*vec.x-B*vec.y-C*vec.z)
    {

    }

    Plane<T>():
        A(0),
        B(0),
        C(0),
        D(0)
    {

    }


    bool CalculateTime(const Vector3<T>& r0,  const Vector3<T>& rd, T& result )
    {
        Vector3<T> vec(A,B,C);

        if ( vec.dot(rd))
        {
            result = -1;
            return false;
        }
        else
        {
            result = (vec.dot(r0) + D)/vec.dot(rd);
            return true;
        }
    }

    T A;
    T B;
    T C;
    T D;
};

For some strange reason when I do the following

    std::set<Plane<float> > s;
    s.insert(Plane<float>(10,20,30,Vector3f(10,30,40)));

this produced a massive error

1>          with
1>          [
1>              T=float
1>          ]
1>          c:\program files (x86)\microsoft visual studio 11.0\vc\include\xtree(2245) : see declaration of 'std::operator <'
1>          c:\program files (x86)\microsoft visual studio 11.0\vc\include\xstddef(179) : while compiling class template member function 'bool std::less<_Ty>::operator ()(const _Ty &,const _Ty &) const'
1>          with
1>          [
1>              _Ty=Plane<float>
1>          ]
1>          c:\program files (x86)\microsoft visual studio 11.0\vc\include\xutility(559) : see reference to function template instantiation 'bool std::less<_Ty>::operator ()(const _Ty &,const _Ty &) const' being compiled
1>          with
1>          [
1>              _Ty=Plane<float>
1>          ]
1>          c:\program files (x86)\microsoft visual studio 11.0\vc\include\type_traits(743) : see reference to class template instantiation 'std::less<_Ty>' being compiled
1>          with
1>          [
1>              _Ty=Plane<float>
1>          ]
1>          c:\program files (x86)\microsoft visual studio 11.0\vc\include\xtree(1028) : see reference to class template instantiation 'std::is_empty<_Ty>' being compiled
1>          with
1>          [
1>              _Ty=std::less<Plane<float>>
1>          ]
1>          c:\program files (x86)\microsoft visual studio 11.0\vc\include\set(44) : see reference to class template instantiation 'std::_Tree<_Traits>' being compiled
1>          with
1>          [
1>              _Traits=std::_Tset_traits<Plane<float>,std::less<Plane<float>>,std::allocator<Plane<float>>,false>
1>          ]
1>          c:\users\awesome2\google drive\university\eng 3gc3\assignment 3\voxelmodeler\voxelmodeler\voxelcube.h(44) : see reference to class template instantiation 'std::set<_Kty>' being compiled
1>          with
1>          [
1>              _Kty=Plane<float>
1>          ]
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\xstddef(180): error C2784: 'bool std::operator <(const std::move_iterator<_RanIt> &,const std::move_iterator<_RanIt2> &)' : could not deduce template argument for 'const std::move_iterator<_RanIt> &' from 'const Plane<T>'
1>          with
1>          [
1>              T=float
1>          ]
1>          c:\program files (x86)\microsoft visual studio 11.0\vc\include\xutility(1983) : see declaration of 'std::operator <'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\xstddef(180): error C2784: 'bool std::operator <(const std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt2> &)' : could not deduce template argument for 'const std::reverse_iterator<_RanIt> &' from 'const Plane<T>'
1>          with
1>          [
1>              T=float
1>          ]
1>          c:\program files (x86)\microsoft visual studio 11.0\vc\include\xutility(1259) : see declaration of 'std::operator <'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\xstddef(180): error C2784: 'bool std::operator <(const std::_Revranit<_RanIt,_Base> &,const std::_Revranit<_RanIt2,_Base2> &)' : could not deduce template argument for 'const std::_Revranit<_RanIt,_Base> &' from 'const Plane<T>'
1>          with
1>          [
1>              T=float
1>          ]
1>          c:\program files (x86)\microsoft visual studio 11.0\vc\include\xutility(1075) : see declaration of 'std::operator <'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\xstddef(180): error C2784: 'bool std::operator <(const std::pair<_Ty1,_Ty2> &,const std::pair<_Ty1,_Ty2> &)' : could not deduce template argument for 'const std::pair<_Ty1,_Ty2> &' from 'const Plane<T>'
1>          with
1>          [
1>              T=float
1>          ]
1>          c:\program files (x86)\microsoft visual studio 11.0\vc\include\utility(232) : see declaration of 'std::operator <'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\xstddef(180): error C2676: binary '<' : 'const Plane<T>' does not define this operator or a conversion to a type acceptable to the predefined operator
1>          with
1>          [
1>              T=float
1>          ]
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T01:24:34+00:00Added an answer on June 15, 2026 at 1:24 am

    The set (as multiset, map and multimap) need a comparision function, or operator. When not specified set, multiset, map and multimap use the std::less functior object to ordinate elements in the set.
    So you have to write something like this

    template <typename T>
    class Plane {
    public:
        friend bool operator < (const Plane<T>& p1, const Plane<T>& p2)
        {
             return ???
        }
    };
    

    As you can see is not a good a class like Plane in a set, maybe is better an unordered_set or simply a std::vector

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given the following template: template <typename T> class wrapper : public T {}; What
Given the following code: template<typename T> class A { public: T t; }; class
Given this code: class X { public: template< typename T > void func( const
Given the following piece of code: template<typename T> class MyContainer { typedef T value_type;
So given the following template functions with partial specialization template<typename T> void foo(vector<T> &in)
Given the following code sequence: #include <iostream> using namespace std; template <typename T> class
Consider the following code: template <typename T> class C2 { public: T method() {
Given the following base class: struct ValueType { String ToString(String const& format) const; };
Given the following code: void f() { class A { template <typename T> void
its templates again ;-) Given the following template member functions and CRTP class: template<typename

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.