Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Technical Support
 Code Inspection "use template keyword ..."
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

anti-freak
New Member

Germany
4 Posts

Posted - Oct 14 2017 :  05:32:29 AM  Show Profile  Reply with Quote
Hey there,

here is a bug report about the Code Inspection feature.

Info:
VA_X.dll file version 10.9.2237.0 built 2017.10.03
DevEnv.exe version 15.0.27004.2002 Community (Visual Studio 2017 English)
Programming Language: c++17




It should not be triggered here (the other snippet is almost the same; again std::forward):



Edited by - anti-freak on Oct 14 2017 05:38:32 AM

feline
Whole Tomato Software

United Kingdom
18746 Posts

Posted - Oct 14 2017 :  10:18:45 AM  Show Profile  Reply with Quote
Your code sample is to small, to many symbols that are not defined, so I have tried to expand this into a small bit of C++ code that will compile. This has given me the code:

template<class T1>
class FelineTemplateBase
{
	FelineTemplateBase<T1>(T1&& _default, std::string _name)	{ }
};

template<class T1>
class PropertyFelineTest : public FelineTemplateBase<T1>
{
	PropertyFelineTest<T1>(T1&& _default, std::string _name, void *_validator = nullptr) :
		super(std::forward<T1>(_default), std::move(_name))
	{

	}
};

code inspection is not suggesting anything for this code however. Can you please try placing this code into your solution, into a header file, and see if Code Inspection suggests anything for you?

zen is the art of being at one with the two'ness
Go to Top of Page

anti-freak
New Member

Germany
4 Posts

Posted - Oct 14 2017 :  11:50:30 AM  Show Profile  Reply with Quote
Interesting..;
While I worked on the project, the suggestion is now gone...
I didn't change much in the file itself; just moved parameters around.
I try to force the suggestion again ;)

But, I can provide you a snippet with more details (still minimized):


#include <iostream>
#include <string>
#include <functional>

namespace prop {
template <class T>
class _Base
{
private:
    T m_Value;
    std::string m_Name;

protected:
    template <class T1>
    void _setValue(T1&& _value)
    {
        m_Value = std::forward<T1>(_value);
    }

public:
    template <class T1>
    _Base(std::string _name, T1&& _value) :
        m_Value(std::forward<T1>(_value)),
        m_Name(std::move(_name))
    {}
    
    const T& operator *() const
    {
        return m_Value;
    }
};

template <class T>
class Property : public _Base<T>
{
private:
    using super = _Base<T>;
    using Validator = std::function<bool(T)>;
    Validator m_Validator;
    
public:
    template <class T1>
    Property(std::string _name, T1&& _value, Validator _validator = nullptr) :
        super(std::move(_name), std::forward<T1>(_value)),
        m_Validator(_validator)
    {}
    
    Property& operator =(const Property& _other) = default;
    template <class T1>
    Property& operator =(T1&& _value)
    {
        if (!m_Validator || m_Validator(_value))
            super::_setValue(std::forward<T1>(_value));
        return *this;
    }
};
}

int main()
{
    prop::Property<int> p{ "test", 0, [](auto _v){
        if (_v <= 0)
        {
            std::cout << "not allowed\n";
            return false;
        }
        return true;
    }};
    
    p = -1;
    p = 5;
    std::cout << *p;
}
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18746 Posts

Posted - Oct 16 2017 :  3:35:57 PM  Show Profile  Reply with Quote
Thank you for the more complete code sample, but like you, I am not seeing any suggestions from Code Inspection here. If this is a bug then it may depend on a fairly specific arrangement of the code, which would explain why a small change stopped this happening. If the problem comes back again, would it be possible to get a copy of the file that is producing the wrong suggestion, purely for testing purposes?

I realise this is often not possible, but it's worth asking on the off chance. If this is possible, please submit the files via the form:

http://www.wholetomato.com/support/contact.asp

including this thread ID or URL in the description, so we can match it up.

zen is the art of being at one with the two'ness
Go to Top of Page

anti-freak
New Member

Germany
4 Posts

Posted - Oct 20 2017 :  09:19:02 AM  Show Profile  Reply with Quote
It happened again, I already send you the file. Perhaps it helps.
If you need a compilable solution (or at least all necessary dependencies), just tell me.

EDIT: Forgot to tell you the Line with the error:





Edited by - anti-freak on Oct 20 2017 09:22:10 AM
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18746 Posts

Posted - Oct 20 2017 :  10:35:06 AM  Show Profile  Reply with Quote
I have the code file, thank you for this:

case=111858

zen is the art of being at one with the two'ness
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18746 Posts

Posted - Oct 20 2017 :  5:39:43 PM  Show Profile  Reply with Quote
I am seeing the same problem here, this code inspection is not right here:

case=111870

also, interestingly, there is no option to turn off this particular code inspection in the VA options dialog:

case=111869

zen is the art of being at one with the two'ness
Go to Top of Page

sean
Whole Tomato Software

USA
2817 Posts

Posted - Dec 18 2017 :  7:25:19 PM  Show Profile  Reply with Quote
case=111869 is fixed in build 2248 -- the Code Inspection is no longer flagged, as it is not currently supported.
Go to Top of Page

anti-freak
New Member

Germany
4 Posts

Posted - Dec 22 2017 :  1:46:27 PM  Show Profile  Reply with Quote
thanks ;)
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000