Skip to content

Commit 0ede79b

Browse files
restriction on ofParameter<bool> constructor when single arg is string/char*
1 parent c98c50a commit 0ede79b

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

libs/openFrameworks/types/ofParameter.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,14 @@ class ofParameter : public ofAbstractParameter {
501501
ofParameter();
502502
ofParameter(const ofParameter<ParameterType> & v);
503503
ofParameter(const ParameterType & v);
504+
505+
template <
506+
typename Arg,
507+
typename = std::enable_if_t<(std::is_convertible_v<Arg, ParameterType> and
508+
!((std::is_same_v<ParameterType,bool>) and !(std::is_arithmetic_v<Arg>)))>
509+
>
510+
ofParameter(const Arg & v);
511+
504512
ofParameter(const std::string & name, const ParameterType & v);
505513
ofParameter(const std::string & name, const ParameterType & v, const ParameterType & min, const ParameterType & max);
506514

@@ -677,7 +685,8 @@ ofParameter<ParameterType>::ofParameter(const ofParameter<ParameterType> & v)
677685
, setMethod(std::bind(&ofParameter<ParameterType>::eventsSetValue, this, std::placeholders::_1)) { }
678686

679687
template <typename ParameterType>
680-
ofParameter<ParameterType>::ofParameter(const ParameterType & v)
688+
template <typename Arg, typename>
689+
ofParameter<ParameterType>::ofParameter(const Arg & v)
681690
: obj(std::make_shared<Value>(v))
682691
, setMethod(std::bind(&ofParameter<ParameterType>::eventsSetValue, this, std::placeholders::_1)) { }
683692

0 commit comments

Comments
 (0)