我正在努力熟悉Haskell的FFI,所以我写了这个小例子:
Main.hs:
{-# LANGUAGE ForeignFunctionInterface #-}
import Foreign.C.Types
import Foreign.Ptr (Ptr)
import Foreign.Marshal.Array (peekArray)
import Foreign.Marshal.Alloc (free)
foreign import ccall "test.h test"
test :: CInt -> Ptr CInt
main = do
let rval = test 6
-- print the array
list <- peekArray 6 rval >>= return . map toInteger
putStrLn $ show list
free rval
-- print it again (it should okay)
putStrLn $ show list
-- try to retrieve it AGAIN after I used free. Should print random …Run Code Online (Sandbox Code Playgroud) 显然今天,MSVC正在尽力说服我切换到铿锵声.但我不会放弃.早些时候,我问这个问题,不知道如何声明std::make_unique作为friend我的班.
我在我的简单场景中得到了一个非常好的答案,当我在wandbox上使用clang尝试它时,它编译得很好.
所以我很高兴回到Visual Studio 2013继续编码.我的代码的一部分是这样的:
// other includes
#include <string>
#include <memory>
template <typename Loader, typename Painter, typename MeshT>
class Model
{
public:
friend std::unique_ptr<Model> std::make_unique<Model>(
const std::string&,
const std::shared_ptr<Loader>&,
const std::shared_ptr<Painter>&);
// Named constructor
static std::unique_ptr<Model> CreateModel(
const std::string& filepath,
const std::shared_ptr<Loader>& loader,
const std::shared_ptr<Painter>& painter)
{
// In case of error longer than the Lord of the Rings trilogy, use the
// line below instead of std::make_unique
//return std::unique_ptr<Model>(new Model(filepath, …Run Code Online (Sandbox Code Playgroud) 我有一个CoordinatorLayout和它里面,两个FloatingActionButton和它们下面一个ScrollView.
问题是即使我可以FloatingActionButtons在屏幕上看到我也无法点击它们.我怀疑那是因为所有onTouch事件都是在处理ScrollView
这是我的布局xml(这可能非常糟糕,所以欢迎任何提示):
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Note: that 80dp padding is:
main_padding + fab_size + 8dp = 80dp
16dp + 56dp + 8dp = 80dp
and it was the only way I could think to add padding
between my FABs
I tried to use app:layout_anchor but my 2
FABs had no padding between them... -->
<android.support.design.widget.FloatingActionButton
style="@style/RefreshFab"
android:id="@+id/fab_send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_marginBottom="80dp"
android:layout_marginEnd="16dp" …Run Code Online (Sandbox Code Playgroud) 我有一个使用 Html、Css、Javascript 和 PhP 的小型网站。该网站包含一个基本的登录页面,用户必须在其中输入密码。然后将所述密码发送到 php,然后 php 使用 SHA-512 对其进行加密并将其添加到数据库中。
于是我开始疑惑。这是做事的首选方式吗?我认为如果我使用 javascript 加密密码并在它已经加密后将其发送到 php 可能会更好。至少那样,原始密码不会在 POST 请求中。
但这真的是正确的方法吗?如果有人能看到我使用的是哪种加密,这不是很糟糕吗?
android ×1
c++ ×1
c++14 ×1
encryption ×1
ffi ×1
haskell ×1
msvc12 ×1
security ×1
unique-ptr ×1