自定义交换函数未在stl排序算法中调用

时间:2018-07-30 08:49:19

标签: c++ sorting visual-c++ swap stl-algorithm

我已经创建了以下类(在头文件中):

HasPtr

尽管我为std::swap对象提供了自定义交换函数,但是在运行以下代码后,stl排序算法而不是上面的swap函数会调用#include "stdafx.h" #include <algorithm> #include "HasPtr.h" #include <vector> int main() { HasPtr hp1("zzzzzzzzzzzzzz"), hp2("aaaaaaa"), hp3("cccccccccc"); std::vector<HasPtr> hpVec{ hp1, hp3, hp2 }; std::sort(hpVec.begin(), hpVec.end()); return 0; }

 <div class="form-group row">
                {!! Form::label("image","Image",["class"=>"col-form-label col-md-3"]) !!} // need change this
                <div class="col-md-5">
                    <img id="preview"
                         src="{{asset((isset($image) && $image->image!='')?'uploads/'.$image->image:'images/noimage.jpg')}}"
                         height="200px" width="200px"/>
                    {!! Form::file("image",["class"=>"form-control","style"=>"display:none"]) !!} // need change this
                    <br/>
                    <a href="javascript:changeProfile();">Add Image</a> |
                    <a style="color: red" href="javascript:removeImage()">Remove</a>
                    <input type="hidden" style="display: none" value="0" name="remove" id="remove">
                </div>
            </div>

怎么了? 预先感谢

0 个答案:

没有答案